// proceed for $openid $object->setOpenid($openid); // proceed for $introduction $object->setIntroduction($introduction); // proceed for $cirtification $object->setCirtification($cirtification); // proceed for $qr_code $object->setQrCode($qr_code); // proceed for $logo $object->setLogo($logo); // proceed for $active $object->setActive($active); // proceed for $last_updated $object->setLastUpdated($last_updated); if ($error_flag == false) { if ($object->save()) { Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功")))); HTML::forwardBackToReferer(); } else { Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败")))); } } } $html = new HTML(); $html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Create Wechat Account', 'zh' => 'Create 微信公共账号')))); $html->output('<div id="wrapper">'); $html->renderOut('core/backend/header'); $html->renderOut('wechat_account/backend/wechat_account_create', array('object' => $object)); $html->output('</div>'); $html->renderOut('core/backend/html_footer'); exit;
$certification = isset($_POST['certification']) ? strip_tags($_POST['certification']) : null; $nickname = isset($_POST['nickname']) ? strip_tags($_POST['nickname']) : null; $qrcode = isset($_POST['qrcode']) ? strip_tags($_POST['qrcode']) : null; $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 = '保存公众号出错'; }