Exemple #1
0
 /**
  * 创建新商店
  */
 public function create_action()
 {
     $account = \TMS_CLIENT::account();
     if ($account === false) {
         return new \ResponseError('长时间未操作,请重新登陆!');
     }
     $creater = \TMS_CLIENT::get_client_uid();
     $creater_name = $account->nickname;
     $shop = array('mpid' => $this->mpid, 'create_at' => time(), 'creater' => $creater, 'creater_name' => $creater_name, 'title' => '新商店', 'pic' => '', 'summary' => '新商店');
     $shopId = $this->model()->insert('xxt_merchant_shop', $shop, true);
     return new \ResponseData($shopId);
 }
Exemple #2
0
 /**
  *
  * $mpid
  * $matterId
  * $matterType
  */
 public function putMatter($mpid, $matter)
 {
     if ($item = $this->byMatter($matter->matter_id, $matter->matter_type)) {
         return false;
     }
     $uid = \TMS_CLIENT::get_client_uid();
     $uname = \TMS_CLIENT::account()->nickname;
     $current = time();
     $item = array('creater' => $uid, 'creater_name' => $uname, 'put_at' => $current, 'mpid' => $mpid, 'matter_type' => $matter->matter_type, 'matter_id' => $matter->matter_id, 'title' => $matter->title, 'pic' => $matter->pic, 'summary' => $matter->summary);
     $id = $this->insert('xxt_shop_matter', $item, true);
     $item = $this->byId($id);
     return $item;
 }
Exemple #3
0
 /**
  * 验证通过后的回调页面 
  */
 public function passed_action($uid)
 {
     $fromip = $this->client_ip();
     $this->model('account')->update_last_login($uid, $fromip);
     /**
      * record account into session and cookie.
      */
     $act = $this->model('account')->byId($uid);
     /**
      * 记录客户端登陆状态
      */
     \TMS_CLIENT::account($act);
     /**
      * 跳转到缺省页
      */
     $this->redirect(TMS_APP_AUTHED);
 }
Exemple #4
0
 /**
  * 修改当前用户的口令
  */
 public function changePwd_action()
 {
     $account = \TMS_CLIENT::account();
     if ($account === false) {
         return new \ResponseError('长时间未操作,请重新登陆!');
     }
     $data = $this->getPostJson();
     /**
      * check old password
      */
     $old_pwd = $data->opwd;
     $result = $this->model('account')->validate($account->email, $old_pwd);
     if ($result->err_code != 0) {
         return $result;
     }
     /**
      * set new password
      */
     $new_pwd = $data->npwd;
     $this->model('account')->change_password($account->email, $new_pwd, $account->salt);
     return new \ResponseData($account->uid);
 }
Exemple #5
0
 /**
  *
  */
 public function addMatter_action()
 {
     $account = \TMS_CLIENT::account();
     if ($account === false) {
         return new \ResponseError('长时间未操作,请重新登陆!');
     }
     $relations = $this->getPostJson();
     $creater = \TMS_CLIENT::get_client_uid();
     $createrName = $account->nickname;
     $channels = $relations->channels;
     $matter = $relations->matter;
     $model = $this->model('matter\\channel');
     foreach ($channels as $channel) {
         $model->addMatter($channel->id, $matter, $creater, $createrName);
     }
     return new \ResponseData('success');
 }
Exemple #6
0
 /**
  * 复制一个登记活动
  */
 public function copy_action($aid = null, $shopid = null)
 {
     $account = \TMS_CLIENT::account();
     if ($account === false) {
         return new \ResponseError('长时间未操作,请重新登陆!');
     }
     $uid = \TMS_CLIENT::get_client_uid();
     $uname = $account->nickname;
     $current = time();
     $enrollModel = $this->model('app\\enroll');
     $codeModel = $this->model('code/page');
     if (!empty($aid)) {
         $copied = $enrollModel->byId($aid);
     } else {
         if (!empty($shopid)) {
             $shopItem = $this->model('shop\\shelf')->byId($shopid);
             $aid = $shopItem->matter_id;
             $copied = $enrollModel->byId($aid);
             $copied->title = $shopItem->title;
             $copied->summary = $shopItem->summary;
             $copied->pic = $shopItem->pic;
         } else {
             return new \ResponseError('没有指定要复制登记活动id');
         }
     }
     /**
      * 获得的基本信息
      */
     $newaid = uniqid();
     $newact['mpid'] = $this->mpid;
     $newact['id'] = $newaid;
     $newact['creater'] = $uid;
     $newact['creater_src'] = 'A';
     $newact['creater_name'] = $uname;
     $newact['create_at'] = $current;
     $newact['title'] = $copied->title . '(副本)';
     $newact['pic'] = $copied->pic;
     $newact['summary'] = $copied->summary;
     $newact['public_visible'] = $copied->public_visible;
     $newact['open_lastroll'] = $copied->open_lastroll;
     $newact['can_signin'] = $copied->can_signin;
     $newact['can_lottery'] = $copied->can_lottery;
     $newact['tags'] = $copied->tags;
     $newact['enrolled_entry_page'] = $copied->enrolled_entry_page;
     $newact['receiver_page'] = $copied->receiver_page;
     $newact['entry_rule'] = json_encode($copied->entry_rule);
     if ($copied->mpid === $this->mpid) {
         $newact['access_control'] = $copied->access_control;
         $newact['authapis'] = $copied->authapis;
         $newact['success_matter_type'] = $copied->success_matter_type;
         $newact['success_matter_id'] = $copied->success_matter_id;
         $newact['failure_matter_type'] = $copied->failure_matter_type;
         $newact['failure_matter_id'] = $copied->failure_matter_id;
     }
     $this->model()->insert('xxt_enroll', $newact, false);
     /**
      * 复制自定义页面
      */
     if ($copied->pages) {
         $modelPage = $this->model('app\\enroll\\page');
         foreach ($copied->pages as $ep) {
             $newPage = $modelPage->add($this->mpid, $newaid);
             $rst = $modelPage->update('xxt_enroll_page', array('title' => $ep->title, 'name' => $ep->name), "aid='{$newaid}' and id={$newPage->id}");
             $data = array('title' => $ep->title, 'html' => $ep->html, 'css' => $ep->css, 'js' => $ep->js);
             $codeModel->modify($newPage->code_id, $data);
         }
     }
     if ($copied->mpid === $this->mpid) {
         /**
          * 复制所属频道
          */
         $sql = 'insert into xxt_channel_matter(channel_id,matter_id,matter_type,creater,creater_src,creater_name,create_at)';
         $sql .= " select channel_id,'{$newaid}','enroll','{$uid}','A','{$uname}',{$current}";
         $sql .= ' from xxt_channel_matter';
         $sql .= " where matter_id='{$aid}' and matter_type='enroll'";
         $this->model()->insert($sql, '', false);
         /**
          * 复制登记事件接收人
          */
         $sql = 'insert into xxt_enroll_receiver(mpid,aid,identity,idsrc)';
         $sql .= " select '{$this->mpid}','{$newaid}',identity,idsrc";
         $sql .= ' from xxt_enroll_receiver';
         $sql .= " where aid='{$aid}'";
         $this->model()->insert($sql, '', false);
         /**
          * 复制ACL
          */
         $sql = 'insert into xxt_matter_acl(mpid,matter_type,matter_id,identity,idsrc,label)';
         $sql .= " select '{$this->mpid}',matter_type,'{$newaid}',identity,idsrc,label";
         $sql .= ' from xxt_matter_acl';
         $sql .= " where matter_id='{$aid}'";
         $this->model()->insert($sql, '', false);
     }
     $act = $enrollModel->byId($newaid);
     return new \ResponseData($act);
 }
Exemple #7
0
 /**
  * 是否已经登录?
  *
  * 允许通过http_auth登录
  *
  */
 private static function _login()
 {
     // directly visit, no login process.
     // analyze the PHP_AUTH_DIGEST variable
     // user exist?
     if (isset($_SERVER['PHP_AUTH_DIGEST'])) {
         if ($data = self::http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) {
             $email = $data['username'];
             $account = self::model('account')->get_account_by_email($email);
             if (!$account) {
                 return false;
             }
             session_destroy();
             TMS_CLIENT::account($account);
             return true;
         }
     }
     return false;
 }
Exemple #8
0
 /**
  * 创建一个多图文素材
  */
 public function create_action()
 {
     $account = \TMS_CLIENT::account();
     if ($account === false) {
         return new \ResponseError('长时间未操作,请重新登陆!');
     }
     $uid = \TMS_CLIENT::get_client_uid();
     $news = $this->getPostJson();
     $d = array();
     $d['mpid'] = $this->mpid;
     $d['creater'] = $uid;
     $d['create_at'] = time();
     $d['creater_src'] = 'A';
     $d['creater_name'] = $account->nickname;
     $d['title'] = isset($news->title) ? $news->title : '新多图文';
     $id = $this->model()->insert('xxt_news', $d, true);
     /**
      * matters
      */
     isset($news->matters) && $this->assign_news_matter($id, $news->matters);
     $news = $this->model('matter\\news')->byId($id);
     return new \ResponseData($news);
 }
Exemple #9
0
 /**
  *
  */
 private function update($id, $nv)
 {
     $account = \TMS_CLIENT::account();
     if ($account === false) {
         return new \ResponseError('长时间未操作,请重新登陆!');
     }
     $pmpid = $this->getParentMpid();
     $nv['modifier'] = \TMS_CLIENT::get_client_uid();
     $nv['modifier_src'] = 'A';
     $nv['modifier_name'] = $account->nickname;
     $nv['modify_at'] = time();
     $rst = $this->model()->update('xxt_article', $nv, "(mpid='{$this->mpid}' or mpid='{$pmpid}') and id='{$id}'");
     return $rst;
 }