function add()
 {
     $model = $this->getModel();
     if (IS_POST) {
         $this->checkPostData();
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $this->_saveKeyword($model, $id);
             // 清空缓存
             method_exists($Model, 'clear') && $Model->clear($id, 'edit');
             D('Scratch')->getScratchInfo($id, true);
             $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         $this->_deal_data();
         $this->display();
     }
 }
 public function edit($model = null, $id = 0)
 {
     is_array($model) || ($model = $this->getModel($model));
     $id || ($id = I('id'));
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 清空旧关键词
         $keyword = $Model->where('id=' . $id)->getField('keyword');
         $keyword = preg_split('/[\\s,;]+/', $keyword);
         // 以空格tab逗号分号分割关键词
         $data['addon'] = 'Extensions';
         foreach ($keyword as $key) {
             $data['keyword'] = trim($key);
             $res = M('keyword')->where($data)->delete();
         }
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
             $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         parent::edit($model, $id);
     }
 }
 function edit()
 {
     $cateMap['token'] = $map['token'] = get_token();
     $map['id'] = $id = I('id');
     $model = $this->getModel('wish_card_content');
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         //读分类名称
         $cate_data['id'] = $_POST['content_cate_id'];
         $_POST['content_cate'] = M('WishCardContentCate')->where($cate_data)->getField('content_cate_name');
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
         }
         // 清空缓存
         method_exists($Model, 'clear') && $Model->clear($id, 'edit');
         $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
     } else {
         $cate = D('WishCardContentCate')->where($cateMap)->select();
         $data = D('WishCardContent')->find($id);
         for ($i = 0; $i < count($cate); $i++) {
             if ($cate[$i]['id'] == $data['content_cate_id']) {
                 $cate[$i]['checked'] = true;
             }
         }
         $this->assign('content_cate', $cate);
         $this->assign('data', $data);
         //dump($cate);
         $this->display(T('Addons://WishCard@WishCard/editWishContent'));
     }
 }
 function edit()
 {
     $map['id'] = $id = I('id');
     $map['token'] = get_token();
     $model = $this->getModel();
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
         }
         // 清空缓存
         method_exists($Model, 'clear') && $Model->clear($id, 'edit');
         $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
     } else {
         $normal_tips = "贺卡模板目前仅支持在贺卡插件目录下由制作人员添加";
         $this->assign('normal_tips', $normal_tips);
         $data = D('WishCard')->find($id);
         $this->assign('data', $data);
         $template = $this->_getTemplateInfo($data['template_cate'], $data['template']);
         $this->assign('template', $template);
         $this->display();
     }
 }
 public function add()
 {
     $model = $this->model;
     $Model = D(parse_name(get_table_name($model['id']), 1));
     $shop_id = $_POST['shop_id'] = $this->shop_id;
     if (IS_POST) {
         if ($_POST['imgs'] && count($_POST['imgs']) > 0) {
             $_POST['imgs'] = implode(',', $_POST['imgs']);
         }
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             D('Common/Keyword')->set($_POST['keyword'], _ADDONS, $id, $_POST['keyword_type'], 'custom_reply_news');
             $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'] . '&shop_id=' . $shop_id));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $extra = $this->getCateData();
         if (!empty($extra)) {
             foreach ($fields as &$vo) {
                 if ($vo['name'] == 'category_id') {
                     $vo['extra'] .= "\r\n" . $extra;
                 }
             }
         }
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         $this->display();
     }
 }
 public function edit($id = 0)
 {
     $model = $this->getModel('credit_config');
     $id || ($id = I('id'));
     // 获取数据
     $data = M(get_table_name($model['id']))->find($id);
     $data || $this->error('数据不存在!');
     if (IS_POST) {
         $act = 'save';
         if ($data['token'] == 0) {
             $_POST['token'] = get_token();
             unset($_POST['id']);
             $act = 'add';
         }
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->{$act}()) {
             // dump($Model->getLastSql());
             $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             // dump($Model->getLastSql());
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->meta_title = '编辑' . $model['title'];
         $this->display('Addons/edit');
     }
 }
    public function add()
    {
        if (IS_POST) {
            $Model = D(parse_name(get_table_name($this->model['id']), 1));
            // 获取模型的字段信息
            $Model = $this->checkAttr($Model, $this->model['id']);
            if ($Model->create() && ($id = $Model->add())) {
                $this->_saveKeyword($this->model, $id);
                // 清空缓存
                method_exists($Model, 'clear') && $Model->clear($id, 'edit');
                $param['reserve_id'] = $this->reserve_id;
                $param['model'] = $this->model['id'];
                $url = U('lists', $param);
                $this->success('添加' . $this->model['title'] . '成功!', $url);
            } else {
                $this->error($Model->getError());
            }
            exit;
        }
        $normal_tips = '字段类型为单选、多选、下拉选择的参数格式第行一项,每项的值和标题用英文冒号分开。如:<br/>0:男<br/>1:女<br/>2:保密<br/>';
        $normal_tips .= '字段类型为级联的参数格式有两种:
				<br/>一是数据源从数据库取,如: type=db&table=common_category&module=shop_category 
				<br/>二是手工输入,如: type=text&data=[广西[南宁,桂林], 广东[广州, 深圳[福田区, 龙岗区, 宝安区]]]';
        $this->assign('normal_tips', $normal_tips);
        parent::common_add($this->model);
    }
 function edit()
 {
     $id = $this->shop_id;
     $model = $this->getModel();
     if (IS_POST) {
         // $_POST ['update_time'] = NOW_TIME;
         $Model = D(parse_name(get_table_name($model['id']), 1));
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
         }
         // 清空缓存
         method_exists($Model, 'clear') && $Model->clear($id, 'edit');
         $this->success('保存' . $model['title'] . '成功!');
     } else {
         $fields = get_model_attribute($model['id']);
         // 获取数据
         $data = D('Shop')->getInfo($id, true);
         $data || $this->error('数据不存在!');
         $token = get_token();
         if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) {
             $this->error('非法访问!');
         }
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->display();
     }
 }
 public function edit($id = 0)
 {
     $model = $this->getModel($this->model);
     $id || ($id = I('id'));
     if (IS_POST) {
         $_POST['module'] = _ADDONS;
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
             $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         // 获取数据
         $data = M(get_table_name($model['id']))->find($id);
         $data || $this->error('数据不存在!');
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->meta_title = '编辑' . $model['title'];
         $this->display();
     }
 }
 public function add()
 {
     $model = $this->model;
     $Model = D(parse_name(get_table_name($model['id']), 1));
     if (IS_POST) {
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $this->_saveKeyword($model, $id, 'custom_reply_text');
             $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $extra = $this->getCateData();
         if (!empty($extra)) {
             foreach ($fields[1] as &$vo) {
                 if ($vo['name'] == 'cate_id') {
                     $vo['extra'] .= "\r\n" . $extra;
                 }
             }
         }
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         $this->display();
     }
 }
Example #11
0
 /**
  * Object constructor
  *
  * @param object  Instance of the rcube_db class
  * @param integer User-ID
  */
 function __construct($dbconn, $user)
 {
     $this->db = $dbconn;
     $this->db_name = get_table_name('contacts');
     $this->user_id = $user;
     $this->ready = $this->db && !$this->db->is_error();
 }
 function export()
 {
     set_time_limit(0);
     // 获取模型信息
     $model = $this->model;
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $grids = $list_data['list_grids'];
     $fields = $list_data['fields'];
     foreach ($grids as $v) {
         if ($v['title'] == '操作') {
             array_pop($grids);
         } else {
             $arr = explode('|', $v['field'][0]);
             if (count($arr) > 1) {
                 $fun[$arr[0]] = $arr[1];
             }
             $ht[$arr[0]] = $v['title'];
         }
     }
     $dataArr[0] = $ht;
     // 搜索条件
     $map = $this->_search_map($model, $fields);
     $map['ask_id'] = $this->ask_id;
     $name = parse_name(get_table_name($model['id']), true);
     $data = M($name)->field(empty($fields) ? true : $fields)->where($map)->order($order)->select();
     if ($data) {
         $qdao = D('AskQuestion');
         foreach ($data as &$vv) {
             $user = get_followinfo($vv['uid']);
             $vv['nickname'] = $user['nickname'];
             $vv['times'] += 1;
             $vv['question_id'] = $qdao->getQuestionTitle($vv['question_id'], $this->ask_id);
             $vv['answer'] = implode(', ', unserialize($vv['answer']));
             $vv['is_correct'] = $vv['is_correct'] == 1 ? '是' : '否';
         }
         foreach ($data as &$vo) {
             foreach ($vo as $name => &$vv) {
                 if (isset($fun[$name])) {
                     if ($fun[$name] == 'get_name_by_status') {
                         $vv = get_name_by_status($vv, $name, $model['id']);
                     } else {
                         $vv = call_user_func($fun[$name], $vv);
                     }
                 }
             }
             foreach ($ht as $key => $val) {
                 $newArr[$key] = empty($vo[$key]) ? ' ' : $vo[$key];
             }
             $vo = $newArr;
         }
         $dataArr = array_merge($dataArr, $data);
     }
     if ($return) {
         return $dataArr;
     } else {
         outExcel($dataArr, $map['module']);
     }
 }
 function __construct($dbconn, $user)
 {
     parent::__construct($dbconn, $user);
     $this->user_id = $user;
     $this->db = $dbconn;
     $this->name = 'Google Addressbook';
     $this->readonly = true;
     $this->groups = false;
     $this->undelete = false;
     $this->db_name = get_table_name('contacts_google');
 }
 /**
  * 发布推送的信息到所有关注用户
  */
 public function send()
 {
     // $this->error ( '群发失败!错误:');
     // return;
     $togroup = I("togroup");
     //生成需要发送的数据
     is_array($model) || ($model = $this->getModel($model));
     !empty($ids) || ($ids = I('id'));
     !empty($ids) || ($ids = array_unique((array) I('ids', 0)));
     !empty($ids) || $this->error('请选择要操作的数据!');
     $Model = M(get_table_name($model['id']));
     $map['id'] = array('in', $ids);
     // 插件里的操作自动加上Token限制
     $token = get_token();
     if (defined('ADDON_PUBLIC_PATH') && !empty($token)) {
         $map['token'] = $token;
     }
     $sendlists = $Model->where($map)->order('sort asc')->select();
     if (!$sendlists) {
         $this->error('请选择要操作的数据!');
     }
     $senddata = array("articles" => array());
     foreach ($sendlists as $key => $value) {
         $senddata['articles'][] = array('thumb_media_id' => $value['thumb_media_id'], 'author' => $value['author'], 'title' => $value['title'], 'content_source_url' => $value['content_source_url'], 'content' => $value['content'], 'digest' => $value['digest'], 'show_cover_pic' => $value['show_cover_pic']);
     }
     //发送数据操作
     $mapinfo['token'] = $token;
     $info = M('member_public')->where($mapinfo)->find();
     $this->assign('info', $info);
     $options = array('token' => 'weiphp', 'appid' => $info['appid'], 'appsecret' => $info['secret']);
     $weObj = new Wechat($options);
     $accesstoken = $weObj->checkAuth($info['appid'], $info['secret']);
     $result = $weObj->uploadnews($senddata);
     if (!$result) {
         $this->error('推送信息生成失败:' . $weObj->errCode . $weObj->errmsg);
     }
     $sendmedia_id = $result['media_id'];
     if ($togroup == -1) {
     } else {
         $result = $weObj->sendall($togroup, $sendmedia_id);
         if ($result) {
             if ($result['errcode'] != 0) {
                 $this->error('群发失败!错误:' . $result['errcode'] . $result['errmsg']);
             } else {
                 $this->success('群发完成:' . $result['errmsg']);
             }
         } else {
             $this->error('群发失败!');
         }
     }
 }
function db_UpdateSeriesCatalog_All()
{
    $result_status = array("inserted" => 0, "updated" => 0);
    $query = 'SELECT MAX(SiteID), MAX(VariableID), MAX(MethodID), MAX(SourceID), MAX(QualityControlLevelID)
            FROM ' . get_table_name('DataValues') . ' GROUP BY SiteID, VariableID, SourceID, MethodID, QualityControlLevelID';
    $result = mysql_query($query);
    if (!$result) {
        die("<p>Error in executing the SQL query " . $query . ": " . mysql_error() . "</p>");
    }
    $result_array = mysql_fetch_rowsarr($result, MYSQL_NUM);
    foreach ($result_array as $r) {
        $status = update_series_catalog($r[0], $r[1], $r[2], $r[3], $r[4]);
    }
}
 /**
  * Get all the fetchmail account configured (can specify a user id to retrieve only account for a single user)
  * @param MDB2 $dbm database connection
  * @param int $user_id
  */
 public function __construct($dbm, $user_id = -1)
 {
     $this->dbm = $dbm;
     $this->position = 0;
     // Retrieve the accounts list
     if ($user_id != -1) {
         $sql_result = $this->dbm->query("SELECT * FROM " . get_table_name('fetchmail_rc') . " WHERE fk_user=?", $user_id);
     } else {
         $sql_result = $this->dbm->query("SELECT * FROM " . get_table_name('fetchmail_rc'));
     }
     while ($account = $this->dbm->fetch_assoc($sql_result)) {
         $fetchmailRc = new fetchMailRc();
         $fetchmailRc->from_array($account);
         $this->datas[] = $fetchmailRc;
     }
 }
 function edit()
 {
     $model = $this->getModel('business_card');
     $map['uid'] = $uid = $this->mid;
     $act = 'edit';
     // 	    $map['uid']=11857;
     $data = M('business_card')->where($map)->find();
     // 	    $id = I ( 'id' );
     // 获取数据
     // 	    $data = M ( get_table_name ( $model ['id'] ) )->find ( $id );
     $data || ($act = 'add');
     // $token = get_token ();
     // if (isset ( $data ['token'] ) && $token != $data ['token'] && defined ( 'ADDON_PUBLIC_PATH' )) {
     // $this->error ( '非法访问!' );
     // }
     if (IS_POST) {
         $_POST['uid'] = $this->mid;
         $_POST['token'] = get_token();
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($act == 'edit') {
             if ($Model->create() && $Model->save()) {
                 // 清空缓存
                 method_exists($Model, 'clear');
                 //     			$url=  '<script language=javascript>history.go(-1);</script>';
                 $this->success('保存' . $model['title'] . '成功!');
             } else {
                 $this->error($Model->getError());
             }
         } else {
             if ($Model->create() && ($id = $Model->add())) {
                 // 清空缓存
                 method_exists($Model, 'clear') && $Model->clear($id, 'add');
                 $this->success('添加' . $model['title'] . '成功!');
             } else {
                 $this->error($Model->getError());
             }
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->display();
     }
 }
 public function lists()
 {
     if (!is_administrator($this->mid)) {
         redirect(addons_url('UserCenter://UserCenter/lists'));
     }
     // $this->assign ( 'add_button', false );
     $this->assign('search_url', U('lists'));
     $model = $this->getModel('keyword');
     $page = I('p', 1, 'intval');
     // 默认显示第一页数据
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $fields = $list_data['fields'];
     // 		foreach ( $list_data ['list_grids'] as &$vo ) {
     // 			if (isset ( $vo ['href'] )) {
     // 				$vo ['href'] = '[DELETE]|删除';
     // 			}
     // 		}
     // 搜索条件
     $map = $this->_search_map($model, $fields);
     $map['token'] = get_token();
     $row = empty($model['list_row']) ? 20 : $model['list_row'];
     empty($fields) || in_array('id', $fields) || array_push($fields, 'id');
     $name = parse_name(get_table_name($model['id']), true);
     $list_data['list_data'] = M($name)->field(empty($fields) ? true : $fields)->where($map)->order('id DESC')->page($page, $row)->select();
     // 分页
     $count = M($name)->where($map)->count();
     if ($count > $row) {
         $page = new \Think\Page($count, $row);
         $page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
         $list_data['_page'] = $page->show();
     }
     $addons = M('addons')->where("type=1")->field('name,title')->select();
     foreach ($addons as $a) {
         $addonsArr[$a['name']] = $a['title'];
     }
     foreach ($list_data['list_data'] as &$vo) {
         $vo['addon'] = $addonsArr[$vo['addon']];
     }
     $this->assign($list_data);
     // dump($list_data);
     $this->display('Addons/lists');
 }
 function lists()
 {
     $isAjax = I('isAjax');
     // $coupon_id = I ( 'coupon_id','' );
     // dump($coupon_id);
     $search = $_REQUEST['name'];
     $top_more_button[] = array('title' => '导入数据', 'url' => U('import', array('mdm' => I('mdm'))));
     $top_more_button[] = array('title' => '导出数据', 'url' => U('output', array('name' => $search)));
     $this->assign('top_more_button', $top_more_button);
     $model = $this->getModel($this->table);
     $page = I('p', 1, 'intval');
     // 默认显示第一页数据
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $fields = $list_data['fields'];
     // 搜索条件
     // $map ['coupon_id'] = $coupon_id;
     $map = $this->_search_map($model, $fields);
     $map['manager_id'] = $this->mid;
     $row = empty($model['list_row']) ? 20 : $model['list_row'];
     empty($fields) || in_array('id', $fields) || array_push($fields, 'id');
     $name = parse_name(get_table_name($model['id']), true);
     $data = M($name)->field(empty($fields) ? true : $fields)->where($map)->order('id DESC')->page($page, $row)->select();
     /* 查询记录总数 */
     $count = M($name)->where($map)->count();
     $list_data['list_data'] = $data;
     // 分页
     if ($count > $row) {
         $page = new \Think\Page($count, $row);
         $page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
         $list_data['_page'] = $page->show();
     }
     if ($isAjax) {
         unset($list_data['list_grids']['phone']);
         unset($list_data['list_grids']['ids']);
         $this->assign($list_data);
         $this->display('lists_data');
     } else {
         $this->assign($list_data);
         $this->display();
     }
 }
Example #20
0
 /**
  * Calendar UI initialization and requests handlers
  */
 public function init()
 {
     if ($this->ready) {
         // already done
         return;
     }
     $sql = 'SELECT * FROM ' . get_table_name('calendars') . ' WHERE tasks=? and user_id=?';
     $result = $this->rc->db->limitquery($sql, 0, 1, 1, $this->rc->user->ID);
     if ($this->rc->db->fetch_assoc($result)) {
         // let the client know that we have to handle tasks
         $this->rc->output->set_env('tasks', true);
         // add taskbar button
         $this->plugin->add_button(array('command' => 'tasks', 'class' => 'button-tasklist', 'classsel' => 'button-tasklist button-selected', 'innerclass' => 'button-inner', 'label' => 'tasklist.navtitle'), 'taskbar');
         $this->plugin->include_stylesheet($this->plugin->local_skin_path() . '/tasklist.css');
         if ($this->rc->output->type == 'html') {
             $this->rc->output->add_header(html::tag('script', array('type' => 'text/javascript', 'src' => 'plugins/libgpl/tasklist/tasklist_base.js')));
         }
     }
     $this->ready = true;
 }
Example #21
0
 public function add()
 {
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($this->model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $this->model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $param['hid'] = $this->hid;
             $param['model'] = $this->model['id'];
             $url = U('lists', $param);
             $this->success('添加' . $this->model['title'] . '成功!', $url);
         } else {
             $this->error($Model->getError());
         }
         exit;
     }
     // $normal_tips = '';
     // $this->assign ( 'normal_tips', $normal_tips );
     parent::common_add($this->model);
 }
 public function del()
 {
     $model = $this->model;
     !empty($ids) || ($ids = I('id'));
     !empty($ids) || ($ids = array_filter(array_unique((array) I('ids', 0))));
     !empty($ids) || $this->error('请选择要操作的数据!');
     $Model = M(get_table_name($model['id']));
     $map['id'] = array('in', $ids);
     // 插件里的操作自动加上Token限制
     $token = get_token();
     if (defined('ADDON_PUBLIC_PATH') && !empty($token)) {
         $map['token'] = $token;
     }
     if ($Model->where($map)->delete()) {
         D('AskQuestion')->setLastQuestion($this->ask_id);
         $this->success('删除成功');
     } else {
         $this->error('删除失败!');
     }
 }
 public function add()
 {
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($this->model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $this->model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $param['survey_id'] = $this->survey_id;
             $param['model'] = $this->model['id'];
             $url = U('lists', $param);
             $this->success('添加' . $this->model['title'] . '成功!', $url);
         } else {
             $this->error($Model->getError());
         }
         exit;
     }
     $normal_tips = '字段类型为单选、多选的参数格式第行一项,每项的值和标题用英文冒号分开。如:<br/>0:男<br/>1:女<br/>2:保密';
     $this->assign('normal_tips', $normal_tips);
     parent::common_add($this->model);
 }
 public function lists()
 {
     $this->assign('add_button', false);
     $this->assign('search_button', false);
     $this->assign('del_button', false);
     $this->assign('check_all', false);
     // 解析列表规则
     $data = $this->_list_grid($this->model);
     $this->assign($data);
     // 搜索条件
     $map = $this->_search_map($this->model, $data['fields']);
     $name = parse_name(get_table_name($this->model['id']), true);
     $list = M($name)->where($map)->order('id DESC')->group('uid')->selectPage();
     foreach ($list['list_data'] as &$vo) {
         $member = get_memberinfo($vo['uid']);
         $vo['truename'] = $member['truename'];
         $vo['mobile'] = $member['mobile'];
     }
     $this->assign($list);
     $this->display();
 }
 function add()
 {
     $model = $this->getModel();
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $this->_saveKeyword($model, $id);
             $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         $this->_deal_data();
         $this->display();
     }
 }
 function card_show()
 {
     $model = $this->getModel('wish_card');
     $Model = D(parse_name(get_table_name($model['id']), 1));
     if (IS_POST) {
         //保存贺卡
         $write_info = session('write_info');
         $post_data = array_merge($write_info, $_POST);
         $post_data['mid'] = get_mid();
         $post_data['token'] = get_token();
         $post_data['create_time'] = time();
         if ($id = $Model->add($post_data)) {
             $data = $post_data;
             $isMake = 1;
         }
     } else {
         $id = I('id');
         $data = $Model->find($id);
         $Model->where('id=' . $id)->setInc('read_count', 1);
         //统计浏览数加1
         $isMake = 0;
     }
     if ($data) {
         $sendUser = get_followinfo($data['mid']);
         $this->assign('sendUser', $sendUser);
         $this->assign('data', $data);
         $shareUrl = addons_url('WishCard://Wap/card_show', array('id' => $id));
         $makeUrl = addons_url('WishCard://Wap/card_type');
         $this->assign('shareUrl', $shareUrl);
         $this->assign('makeUrl', $makeUrl);
         $this->assign('isMake', $isMake);
         //是否制作的
         //dump($shareUrl);
         $template = ONETHINK_ADDON_PATH . 'WishCard/View/default/Template/' . $data['template_cate'] . '/' . $data['template'] . '/index.html';
         $this->assign("assetsPath", SITE_URL . '/Addons/WishCard/View/default/Template/' . $data['template_cate'] . '/' . $data['template']);
         $this->display($template);
     } else {
         $this->error("没有该模板或模板保存不成功!");
     }
 }
Example #27
0
 function lists()
 {
     $this->assign('add_button', false);
     $this->assign('del_button', false);
     $this->assign('search_button', false);
     $this->assign('check_all', false);
     $top_more_button[] = array('title' => '导出数据', 'url' => U('export', array('target_id' => I('target_id'))));
     $this->assign('top_more_button', $top_more_button);
     $model = $this->getModel($this->table);
     $page = I('p', 1, 'intval');
     // 默认显示第一页数据
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     unset($list_data['list_grids'][2]);
     $grids = $list_data['list_grids'];
     $fields = $list_data['fields'];
     // 搜索条件
     $map['addon'] = $this->addon;
     $map['target_id'] = I('target_id');
     $map['token'] = get_token();
     session('common_condition', $map);
     $map = $this->_search_map($model, $fields);
     $row = empty($model['list_row']) ? 20 : $model['list_row'];
     empty($fields) || in_array('id', $fields) || array_push($fields, 'id');
     $name = parse_name(get_table_name($model['id']), true);
     $data = M($name)->field(empty($fields) ? true : $fields)->where($map)->order('id DESC')->page($page, $row)->select();
     /* 查询记录总数 */
     $count = M($name)->where($map)->count();
     $list_data['list_data'] = $data;
     // 分页
     if ($count > $row) {
         $page = new \Think\Page($count, $row);
         $page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
         $list_data['_page'] = $page->show();
     }
     $this->assign($list_data);
     // dump($list_data);
     $this->display();
 }
 public function add()
 {
     if (IS_POST) {
         $Model = D(parse_name(get_table_name($this->model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $this->model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $param['test_id'] = $this->test_id;
             $param['model'] = $this->model['id'];
             $url = U('lists', $param);
             $this->success('添加' . $this->model['title'] . '成功!', $url);
         } else {
             $this->error($Model->getError());
         }
         exit;
     }
     $this->_tip();
     $fields = get_model_attribute($this->model['id']);
     $this->assign('fields', $fields);
     $this->meta_title = '新增' . $this->model['title'];
     $this->display();
 }
 public function add()
 {
     is_array($model) || ($model = $this->getModel($model));
     if (IS_POST) {
         //	$_POST ['token'] = get_token ();
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $this->_saveKeyword($model, $id);
             $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         $templateFile || ($templateFile = $model['template_add'] ? $model['template_add'] : '');
         $this->display($templateFile);
     }
 }
 public function add()
 {
     $model = $this->getModel('Message');
     if (IS_POST) {
         if (!C('SEND_GROUP_MSG')) {
             $this->error('抱歉,您的公众号没有群发消息的权限');
         }
         $send_type = I('send_type', 0, 'intval');
         $group_id = I('group_id', 0, 'intval');
         $send_openids = I('send_openids');
         if ($send_type == 0) {
             $_POST['msg_id'] = $this->_send_by_group($group_id);
         } else {
             $_POST['msg_id'] = $this->_send_by_openid($send_openids);
         }
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && ($id = $Model->add())) {
             $this->_saveKeyword($model, $id);
             // 清空缓存
             method_exists($Model, 'clear') && $Model->clear($id, 'edit');
             $this->success('添加' . $model['title'] . '成功!', U('add'));
         } else {
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id'], $model['field_sort']);
         $this->assign('fields', $fields);
         $this->meta_title = '新增' . $model['title'];
         !C('SEND_GROUP_MSG') && $this->assign('normal_tips', '温馨提示:目前微信仅开放认证公众号的群发消息权限,未认证公众号无法使用此功能');
         $map['token'] = get_token();
         $map['manager_id'] = $this->mid;
         $map['is_del'] = 0;
         $group_list = M('auth_group')->where($map)->select();
         $this->assign('group_list', $group_list);
         $this->display();
     }
 }