/** * 还原头像 * * @param int $uid * @param string $type 还原类型-一种默认头像face*,一种是禁止头像ban* * @return boolean */ public function defaultAvatar() { $uid = $this->getInput('uid'); $type = $this->getInput('type'); $srv = Windid::load('user.srv.WindidUserService'); return $srv->defaultAvatar($uid, $type); }
/** * 还原头像 * * @param int $uid * @param string $type 还原类型-一种默认头像face*,一种是禁止头像ban* * @return boolean */ public function defaultAvatar($uid, $type = 'face') { $client = Windid::client(); if ($client->windid == 'local') { $srv = Windid::load('user.srv.WindidUserService'); $result = $srv->defaultAvatar($uid, $type); return (int) $result; } $params = array('uid' => $uid, 'type' => $type); return WindidApi::open('avatar/default', array(), $params); }
public function registerTmpUser($from = 1, $key = '') { //need to check if registered user exists or not if (empty($key) == false) { //if has key, then check if this key has user or not $tmpFound = $this->getbyKey($from, $key); if (empty($tmpFound) == false) { //if has user info, then return user's information $userid = $tmpFound['userid']; return Windid::load('user.WindidUser')->getUserByUid($userid, WindidUser::FETCH_MAIN); } } Wind::import('SRC:service.user.dm.PwUserInfoDm'); $userDm = new PwUserInfoDm(); $password = substr(md5(rand() . '123456'), 0, 15); //order number: 13 number and 3 random number $currentTimeStamp = strtotime("+0 day"); $prefix = 'tmp'; if ($from == 1) { $prefix = 'web'; } else { if ($from == 2) { $prefix = 'app'; } else { if ($from == 3) { $prefix = 'wx'; } } } $username = $prefix . rand(10, 99) . $currentTimeStamp; $userDm->setUsername($username); $userDm->setPassword($password); $userDm->setRegdate(Pw::getTime()); $userDm->setLastvisit(Pw::getTime()); $userDm->setRegip(Wekit::app()->clientIp); Wind::import('SRV:user.srv.PwRegisterService'); Wind::import('APPS:u.service.helper.PwUserHelper'); Wind::import('SRV:user.validator.PwUserValidator'); Wind::import('Wind:utility.WindValidator'); Wind::import('SRV:user.srv.PwLoginService'); $registerService = new PwRegisterService(); $registerService->setUserDm($userDm); $info = $registerService->register(); $userService = Wekit::load('user.srv.PwUserService'); $userService->updateLastLoginData($info['uid'], Wekit::app()->clientIp); $userService->createIdentity($info['uid'], $password); $dm = new App_Tmpuser_Dm(); $dm->setUserId($info['uid']); $dm->setFrom($from); $dm->setKey($key); $this->add($dm); return $info; }
public function getStore() { $ds = Windid::load('config.WindidConfig'); $stores = $ds->getValues('storage'); $config = $ds->getValues('attachment'); $config = $config['storage.type']; if (!$config || !isset($stores[$config])) { $cls = 'WINDID:library.storage.WindidStorageLocal'; } else { $store = unserialize($stores[$config]); $cls = $store['components']['path']; } $srv = Wind::import($cls); return new $srv(); //$this->store = Wind::getComponent($this->bhv->isLocal ? 'windidLocalStorage' : 'windidStorage'); }
/** * 编辑用户信息操作 * * @return voido */ public function doEditAction() { $uid = (int) $this->getInput('uid', 'post'); if (!$uid) { $this->showError('WINDID:fail'); } Wind::import('WINDID:service.user.dm.WindidUserDm'); $dm = new WindidUserDm($uid); //用户信息 $dm->setUsername($this->getInput('username', 'post')); list($password, $repassword) = $this->getInput(array('password', 'repassword'), 'post'); if ($password) { if ($password != $repassword) { $this->showError('USER:user.error.-20'); } $dm->setPassword($password); } $dm->setEmail($this->getInput('email', 'post')); list($question, $answer) = $this->getInput(array('question', 'answer'), 'post'); switch ($question) { case '-2': $dm->setQuestion('', ''); break; case '-1': default: break; } $dm->setRegdate(Pw::str2time($this->getInput('regdate', 'post'))); $dm->setRegip($this->getInput('regip', 'post')); //基本资料 $dm->setRealname($this->getInput('realname', 'post')); $dm->setGender($this->getInput('gender', 'post')); $birthday = $this->getInput('birthday', 'post'); if ($birthday) { $bir = explode('-', $birthday); isset($bir[0]) && $dm->setByear($bir[0]); isset($bir[1]) && $dm->setBmonth($bir[1]); isset($bir[2]) && $dm->setBday($bir[2]); } else { $dm->setBday('')->setByear('')->setBmonth(''); } list($hometown, $location) = $this->getInput(array('hometown', 'location'), 'post'); /* @var $srv PwAreaService */ $srv = Wekit::load('area.srv.PwAreaService'); $areas = $srv->fetchAreaInfo(array($hometown, $location)); $dm->setLocation($location, isset($areas[$location]) ? $areas[$location] : ''); $dm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : ''); $dm->setHomepage($this->getInput('homepage', 'post')); $dm->setProfile($this->getInput('profile', 'post')); //交易信息 $dm->setAlipay($this->getInput('alipay', 'post')); $dm->setMobile($this->getInput('mobile', 'post')); //联系信息 $dm->setEmail($this->getInput('email', 'post')); $dm->setAliww($this->getInput('aliww', 'post')); $dm->setQq($this->getInput('qq', 'post')); $dm->setMsn($this->getInput('msn', 'post')); $ds = Windid::load('user.WindidUser'); $result = $ds->editUser($dm); if ($result instanceof PwError) { $this->showError($result->getError()); } $srv = Windid::load('notify.srv.WindidNotifyClient'); $srv->send('202', $dm->getData(), true); $this->showMessage('WINDID:success', 'windid/user/edit?uid=' . $uid); }
/** * 执行用户注册 */ public function quickRegisterAction() { $registerService = new PwRegisterService(); $registerService->setUserDm($this->_getUserDm()); /*[u_regsiter]:插件扩展*/ $this->runHook('c_register', $registerService); if (($info = $registerService->register()) instanceof PwError) { $this->showError($info->getError()); } else { Wind::import('SRV:user.srv.PwLoginService'); $service = new PwLoginService(); Windid::load('user.WindidUser'); $info = $service->sysUser($info['uid']); $identity = PwLoginService::createLoginIdentify($info); $identity = base64_encode($identity); $userService = Wekit::load('user.srv.PwUserService'); $userService->createIdentity($info['uid'], $info['password']); $this->forwardRedirect(WindUrlHelper::createUrl('app/4tschool/orderpreview/run', array("message" => $message))); } }
protected function _beforeUpdate() { if (!$this->uid) { return new WindidError(WindidError::FAIL); } if (isset($this->_data['password'])) { $this->_data['salt'] = WindUtility::generateRandStr(6); $this->_data['password'] = WindidUtility::buildPassword($this->_data['password'], $this->_data['salt']); } if (isset($this->_data['question']) && isset($this->_data['answer'])) { $this->_data['safecv'] = $this->_data['question'] ? substr(md5($this->_data['question'] . $this->_data['answer']), 8, 8) : ''; } if (isset($this->_data['old_password'])) { $user = Windid::load('user.WindidUser')->getUserByUid($this->uid, WindidUser::FETCH_MAIN); if (WindidUtility::buildPassword($this->_data['old_password'], $user['salt']) != $user['password']) { return new WindidError(WindidError::PASSWORD_ERROR); } } return true; }
private function _getNotifyLogDs() { return Windid::load('notify.WindidNotifyLog'); }
public function __construct() { $this->_config = Windid::load('config.WindidConfig')->getValues('attachment'); }
private function _getConfigDs() { return Windid::load('config.WindidConfig'); }
function bind_user($uid = 0) { if ($uid == 0) { $uid = $this->get_uid(); } Wind::import('SRV:user.srv.PwLoginService'); $service = new PwLoginService(); //$this->runHook('c_login_dorun', $login); Windid::load('user.WindidUser'); $info = $service->sysUser($uid); $identity = PwLoginService::createLoginIdentify($info); $identity = base64_encode($identity); $userService = Wekit::load('user.srv.PwUserService'); $userService->updateLastLoginData($info['uid'], $this->getRequest()->getClientIp()); $userService->createIdentity($info['uid'], $info['password']); //到主页去 $this->forwardRedirect(WindUrlHelper::createUrl('app/4tschool/index/run')); $this->showMessage('欢迎回来…', '/'); }
private function _getMessageService() { return Windid::load('message.srv.WindidMessageService'); }
public function makeOrderAction() { //get data $merchandisesInfo = $this->getInput("merchandisesInfo", "post"); $id = $this->getInput("id", "post"); $to = $this->getInput("orderContactor", "post"); $phone = $this->getInput("orderPhone", "post"); $address = $this->getInput("orderAddress", "post"); $note = $this->getInput("orderRemark", "post"); $orderExpressTime = $this->getInput("orderExpressTime", "post"); $orderHour = $this->getInput('orderHour', "post"); $orderMinutes = $this->getInput('orderMinutes', "post"); $orderTime = $orderHour . ':' . $orderMinutes; $schoolId = $this->getCurrentSchoolId(); if (empty($merchandisesInfo)) { //show not correct message return; } else { $merchandisesInfo = (array) json_decode($merchandisesInfo); } $to = trim($to); $phone = trim($phone); $address = trim($address); if (empty($to) || empty($phone) || empty($address)) { echo '无效的数据'; die; } $orderItems = $merchandisesInfo['merchandises']; $shopDeduct = array(); //calculate the promo $orderMerchandiseList = $this->jcart->get_contents(); $promos = $this->_getPromoDs()->matchedPromoInCart($orderMerchandiseList); //calculate deduct price foreach ($promos['Match'] as $item) { if ($item['ShopId'] == $shopid) { $shopDeduct['ShopId'] += $item['Deduct']; } } $hasException = false; $userid = $this->loginUser->uid; $this->_getOrderAddressDs()->addorUpdateOrderAddress($id, $userid, $to, $address, $phone); $newCreated = false; if ($userid <= 0) { //generate tmp userid $newInfo = $this->_getTmpUserDS()->registerTmpUser(1); $userid = $newInfo['uid']; $newCreated = true; } try { //start transaction $this->_getMyOrderDS()->startTran(); $generatedIds = $this->_getMyOrderDS()->makeOrder($userid, $schoolId, $orderItems, $to, $phone, $address, $note, '网站'); } catch (Exception $e) { $hasException = true; $this->_getMyOrderDS()->rollBack(); } if ($hasException == false) { $message = "下单成功"; $this->_getMyOrderDS()->commit(); } else { $message = "下单失败,请联系系统管理员"; } //清空购物车 $this->jcart->empty_cart(); if ($newCreated == true) { Wind::import('SRV:user.srv.PwLoginService'); $service = new PwLoginService(); Windid::load('user.WindidUser'); $info = $service->sysUser($userid); $identity = PwLoginService::createLoginIdentify($info); $identity = base64_encode($identity); $userService = Wekit::load('user.srv.PwUserService'); $userService->createIdentity($info['uid'], $info['password']); //跳转到我的订单的画面 $this->forwardRedirect(WindUrlHelper::createUrl('app/4tschool/schoolorder/myorder', array("message" => $message))); } else { //跳转到我的订单的画面 $this->forwardRedirect(WindUrlHelper::createUrl('app/4tschool/schoolorder/myorder', array("message" => $message))); } }
/** * windid更新 * * @return boolean */ private function _writeWindid() { $baseUrl = Wind::getApp()->getRequest()->getBaseUrl(true); $key = md5(WindUtility::generateRandStr(10)); $charset = Wind::getApp()->getResponse()->getCharset(); $charset = str_replace('-', '', strtolower($charset)); if (!in_array($charset, array('gbk', 'utf8', 'big5'))) { $charset = 'utf8'; } Wind::import('WINDID:service.app.dm.WindidAppDm'); $dm = new WindidAppDm(); $dm->setApiFile('windid.php')->setIsNotify('1')->setIsSyn('1')->setAppName('phpwind9.0')->setSecretkey($key)->setAppUrl($baseUrl)->setCharset($charset)->setAppIp(''); $result = Windid::load('app.WindidApp')->addApp($dm); if ($result instanceof WindidError) { $this->showError('INSTALL:windid.init.fail'); } $config = array('windid' => 'local', 'serverUrl' => $baseUrl, 'clientId' => (int) $result, 'clientKey' => $key, 'clientDb' => 'mysql', 'clientCharser' => $charset); WindFile::savePhpData(Wind::getRealPath('ROOT:conf.windidconfig.php', true), $config); return true; }
/** * * @return WindidUser */ private static function _getUserService() { return Windid::load('user.WindidUser'); }
/** * 获取配置信息 * * @param string $namespace 获取指定域的配置信息 * @return array */ public static function getConfig($namespace) { $array = Windid::load('config.WindidConfig')->getConfig($namespace); return self::_formatConfig($array); }
private function _getNotifyService() { return Windid::load('notify.srv.WindidNotifyServer'); }
/** * @return WindidSchool */ protected function _getSchoolDs() { return Windid::load('school.WindidSchool'); }
private function _getAppDs() { return Windid::load('app.WindidApp'); }
/** * 将数据持久化到数据库 */ public function flush() { $service = Windid::load('config.WindidConfig'); $service->setConfigs($this->namespace, $this->config); }
private function _getAreaDs() { return Windid::load('area.WindidArea'); }
private function _getNotifyClient() { return Windid::load('notify.srv.WindidNotifyClient'); }
/** * 学校Ds * * @return WindidSchool */ private function _getDs() { return Windid::load('school.WindidSchool'); }
/** * * Enter description here ... * @return PwUser */ private function _getUserDs() { return Windid::load('user.WindidUser'); }