public function delete() { $table_name_prefix = 'user_' . $this->getId(); // delete all his wechat_account first, as the deletion can cast onto global accounts foreach (UserWechatAccount::findAll($this->getId()) as $account) { $account->delete(); } // delete user tables parent::dropTableByName($table_name_prefix . '_read'); parent::dropTableByName($table_name_prefix . '_account'); parent::dropTableByName($table_name_prefix . '_category'); return parent::delete(); }
<?php require_permission('manager feeds'); $html = new HTML(); $html->renderOut('site/html_header', array('title' => '公众号 :: ' . $settings['sitename'], 'body_class' => 'accounts')); $html->renderOut('site/header/blank'); $html->renderOut('site/nav/main'); $html->renderOut('site/accounts', array('accounts' => UserWechatAccount::findAll())); $html->renderOut('site/footer'); $html->renderOut('site/html_footer');
<div class="container" id="body"> <?php if ($articles) { foreach ($articles as $article) { $subscribed = false; if ($wechat_account = WechatAccount::findByOpenid($article['openid'])) { if (UserWechatAccount::findByWechatAccountId($wechat_account->getId())) { $subscribed = true; } } ?> <article class="row article"> <div class="col-xs-12 content"> <div class="inner"> <div class="left"> <img class="lazyloading" src="<?php echo uri('modules/site/assets/images/ajax-loader-2.gif'); ?> " data-source="<?php echo $article['thumb']; ?> " /> </div> <div class="middle"> <?php if (isset($article['title'])) { ?> <h2><?php echo $article['title']; ?> </h2>
$response->status = 'error'; $response->message = '您没有权限进行此操作'; echo json_encode($response); exit; } $openid = isset($_POST['openid']) ? strip_tags($_POST['openid']) : null; $wechat_account = WechatAccount::findByOpenid($openid); // check if the account exists if ($wechat_account == null) { $response->status = 'error'; $response->message = '此公众号不存在,无法退订'; echo json_encode($response); exit; } // check if the user has subscribed the account $user_wechat_account = UserWechatAccount::findByWechatAccountId($wechat_account->getId()); if (!$user_wechat_account) { $response->status = 'error'; $response->message = '您并没有订阅此公众号,无法退订'; echo json_encode($response); exit; } // unsubscribe if ($user_wechat_account->delete()) { $response->status = 'success'; } else { $response->status = 'error'; $response->message = '删除订阅失败'; } echo json_encode($response); exit;
$logo = isset($_POST['logo']) ? strip_tags($_POST['logo']) : null; // if wechat account hasn't been added globally, we add it $wechat_account = WechatAccount::findByOpenid($openid); if ($wechat_account == null) { $wechat_account = new WechatAccount(); $wechat_account->setDescription($description); $wechat_account->setCertification($certification); $wechat_account->setOpenid($openid); $wechat_account->setWechatId($wechatid); $wechat_account->setLogo($logo); $wechat_account->setQrCode($qrcode); $wechat_account->setNickname($nickname); $wechat_account->save(); } $user_wechat_account = UserWechatAccount::findByWechatAccountId($wechat_account->getId()); if ($user_wechat_account) { $response->status = 'error'; $response->message = '此公众号已添加'; } else { $user_wechat_account = new UserWechatAccount(); $user_wechat_account->setAccountId($wechat_account->getId()); $user_wechat_account->setCategoryId(1); if ($user_wechat_account->save()) { $response->status = 'success'; } else { $response->status = 'error'; $response->message = '保存公众号出错'; } } echo json_encode($response); exit;