public function actionNotifications($id = 0, $action = '') { if ($id) { $notify = Notify::model()->findByPK($id); if (!$notify) { throw new CHttpException(404, Yii::t('errors', 'Wrong notify')); } elseif ($action) { if ($notify->status == 2 || $notify->status == 3) { throw new CHttpException(404, Yii::t('errors', 'Status already set')); } if ($notify->shared_id) { $cam = Shared::model()->findByPK($notify->shared_id); if (!$cam) { $notify->delete(); throw new CHttpException(404, Yii::t('errors', 'Wrong cam')); } } else { $notify->delete(); throw new CHttpException(404, Yii::t('errors', 'Wrong cam')); } $n = new Notify(); $id = Yii::app()->user->getId(); if ($action == 'approve') { //TODO specify user and cam $n->note(Yii::t('user', 'User approve shared cam'), array($id, $notify->creator_id, 0)); $cam->is_approved = 1; $cam->save(); $notify->status = 2; $notify->save(); } elseif ($action == 'disapprove') { $n->note(Yii::t('user', 'User decline shared cam'), array($id, $notify->creator_id, 0)); $cam->is_approved = 0; $cam->save(); $notify->status = 3; $notify->save(); } else { throw new CHttpException(404, Yii::t('errors', 'Wrong action')); } } else { throw new CHttpException(404, Yii::t('errors', 'Wrong action')); } } $new = Notify::model()->findAllByAttributes(array('dest_id' => Yii::app()->user->getId(), 'status' => 1)); $old = Notify::model()->findAllByAttributes(array('dest_id' => Yii::app()->user->getId(), 'status' => array(0, 2, 3)), array('order' => 'time DESC')); foreach ($new as $notify) { if ($notify->shared_id == 0) { $notify->status = 0; $notify->save(); } } $this->render('notify', array('new' => $new, 'old' => $old)); }
function testGetNonEnglishRealm() { $client = Shared::Client(); $client->setRegion('eu'); $realm = $client->getRealmApi()->getRealm('Термоштепсель'); $this->assertNotEquals(false, $realm); $this->assertArrayHasKey('type', $realm); $this->assertArrayHasKey('queue', $realm); $this->assertArrayHasKey('status', $realm); $this->assertArrayHasKey('population', $realm); $this->assertArrayHasKey('name', $realm); $this->assertArrayHasKey('slug', $realm); }
protected function getTemplateContent($input) { if (!empty($input['label'])) { $content = '<div class="gcore-input gcore-display-table" id="custom_' . $input['id'] . '">'; } if (!empty($input['pre_content'])) { $content .= $input['pre_content']; } $content .= parent::openInputTag($input); // Abre $content .= ' class="form-control A ' . $input['class'] . '"'; if (!empty($input['id'])) { $content .= ' id="' . $input['id'] . '"'; } if (!empty($input['name'])) { $content .= ' name="' . $input['name'] . '"'; } if (!empty($input['value'])) { $content .= ' value="' . $input['value'] . '"'; } if (!empty($input['data']) && !empty($input['data_name'])) { $content .= ' data-' . $input['data_name'] . '="' . $input['data'] . '"'; } $content .= ' ' . $input['extra_param']; $content .= ' >'; if ($input['type'] == "select" || $input['type'] == "datalist" || $input['type'] == "radiogroup") { if ($input['type'] == "datalist") { $content .= '<datalist id="' . $input['datalist_id'] . '">'; } if (!empty($input['placeholder'])) { $default_option = array("", $input['placeholder']); } $content .= parent::buildSelect($input, $default_option); } /* if (!empty($input['label'])) { $content .= "</div>"; } */ if (!empty($input['inside_post_content'])) { $content .= $input['inside_post_content']; } $content .= parent::closeInputTag($input); if (!empty($input['outside_post_content'])) { $content .= $input['outside_post_content']; } return $content; }
public function save() { $id = Yii::app()->user->getId(); foreach ($this->camBuff as $cam) { foreach ($this->emailBuff as $user) { $n = new Notify(); $shared = Shared::model()->findByAttributes(array('owner_id' => $id, 'user_id' => $user->id, 'cam_id' => $cam->id, 'is_public' => 0)); if (!$shared) { $shared = new Shared(); $shared->owner_id = $id; $shared->user_id = $user->id; $shared->cam_id = $cam->id; } if ($this->type == 'assign') { $shared->is_approved = 1; } $shared->save(); $n->note(Yii::t('cams', 'You granted access to camera {cam}', array('{cam}' => $cam->name)), array($id, $user->id, $shared->id), intval($this->type == 'assign') * 2); } } return true; }
$prepare = $this->prepareActivity($activity, array('user' => $user)); if (is_error($prepare)) { header('Location: ' . $this->createMobileUrl('activity', array('actid' => $activity['actid']))); exit; } $uid = intval($_GPC['owner']); $owner = $f->getOne($uid); if (empty($owner)) { message('访问错误', $activity['guide'], 'info'); } if ($owner['uid'] == $user['uid']) { header('Location: ' . $this->createMobileUrl('activity', array('actid' => $activity['actid']))); exit; } require_once MB_ROOT . '/source/Shared.class.php'; $s = new Shared($activity); if ($_W['ispost']) { $input = array(); $input['owner'] = $owner['uid']; $input['helper'] = $user['uid']; $input['dateline'] = TIMESTAMP; $ret = $s->createHelp($input); if (is_error($ret)) { exit($ret['message']); } else { exit('success'); } } $footer_off = true; $_W['page']['title'] = $activity['title']; $_share = array();
public function doMobileRedShared() { global $_W, $_GPC; $modulePublic = '../addons/wwx_fxxt/style/static/'; require_once WWX_FXXT_ROOT . '/class/Activity.class.php'; require_once WWX_FXXT_ROOT . '/class/Fans.class.php'; require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; $a = new Activity(); $f = new Fans(); $user = $this->redauth(); ///74.判断红包领取及用户信息记录。 $id = $_GPC['actid']; $id = intval($id); $activity = $a->getOne($id); /**Activity:2.根据活动ID查询活动内容及设置等**/ $prepare = $this->prepareActivity($activity, array('user' => $user)); ///75.查询红包活动的所有限制条件并输出。 if (is_error($prepare)) { header('Location: ' . $this->createMobileUrl('redactivity', array('actid' => $activity['actid']))); exit; } $uid = intval($_GPC['owner']); $owner = $f->getOne($uid); /**FANS:3.根据用户UID或OPENID查询记录中的用户信息**/ if (empty($owner)) { message('访问错误', $activity['guide'], 'info'); } if ($owner['uid'] == $user['uid']) { header('Location: ' . $this->createMobileUrl('redactivity', array('actid' => $activity['actid']))); exit; } require_once WWX_FXXT_ROOT . '/class/Shared.class.php'; $s = new Shared($activity); if ($_W['ispost']) { $input = array(); $input['owner'] = $owner['uid']; $input['helper'] = $user['uid']; $input['dateline'] = TIMESTAMP; $ret = $s->createHelp($input); /**Shared:4.增加一次助力记录**/ if (is_error($ret)) { exit($ret['message']); } else { exit('success'); } } $footer_off = true; $_W['page']['title'] = $activity['title']; $mid = $this->getMid(); ///11.查询自身wwx_fxxt_member分销表会员ID $_share = array(); $_share['title'] = $activity['share']['title']; $_share['desc'] = $activity['share']['content']; $_share['imgUrl'] = tomedia($activity['share']['image']); $_share['link'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('redshared', array('actid' => $activity['actid'], 'owner' => $user['uid'], 'mid' => $mid, 'joinway' => 2)), 2); $got = $a->getRecord($user['uid'], $id); /**Activity:8.查询活动红包领取信息。**/ //分享集红包 $help = array(); $help['total'] = $activity['tag']['helps']; $help['already'] = $s->helpsCount($owner['uid']); /**Shared:2.获取指定用户的被助力总数**/ $help['isok'] = $help['already'] >= $help['total']; $help['rank'] = $s->getHelpRank($owner['uid'], $user['uid']); /**Shared:5.获取指定用户助力特定用户的名次**/ $activity['tag']['label'] = htmlspecialchars_decode($activity['tag']['label']); $activity['tag']['label'] = str_replace('{nickname}', $owner['nickname'], $activity['tag']['label']); $activity['tag']['request'] = htmlspecialchars_decode($activity['tag']['request']); $activity['tag']['request'] = str_replace('{nickname}', $owner['nickname'], $activity['tag']['request']); include $this->template('redactivity_shared_help'); }
<?php global $_W, $_GPC; require_once MB_ROOT . '/source/Shared.class.php'; require_once MB_ROOT . '/source/Fans.class.php'; $f = new Fans(); $s = new Shared(); $uid = intval($_GPC['owner']); $owner = $f->getOne($uid); if (empty($owner)) { message('访问错误', $activity['guide'], 'info'); } $user = $this->auth(); $activity = $this->getActivity(true, array('user' => $user)); if (is_error($activity)) { message($activity['message']); } if ($owner['uid'] == $user['uid']) { exit('不能帮给自己发红包啊'); } else { $rank = $s->getHelpRank($owner['uid'], $user['uid']); if (!empty($rank)) { exit('您已经向这个好友发过红包啦'); } else { $rec = array(); $rec['from'] = $owner['uid']; $rec['to'] = $user['uid']; $rec['dateline'] = TIMESTAMP; $s->createHelp($rec); exit('success'); }
protected function setUp() { $this->api = Shared::Client()->getCharacterApi(); }
protected function setUp() { $this->api = Shared::Client()->getGuildApi(); }
public static function getAvailableCams() { $id = Yii::app()->user->getId(); $public = array(); $publicAll = Cams::model()->findAllByAttributes(array('is_public' => 1)); $shared = Shared::model()->findAllByAttributes(array('user_id' => $id, 'is_public' => 0)); foreach ($shared as $key => $value) { if (!isset($value->cam->id)) { $value->delete(); unset($shared[$key]); } } $publicEdited = Shared::model()->findAllByAttributes(array('user_id' => $id, 'is_public' => 1), array('index' => 'cam_id')); foreach ($publicAll as $cam) { if (isset($publicEdited[$cam->id])) { $public[] = $publicEdited[$cam->id]; } else { $public[] = $cam; } } $myCams = Cams::model()->findAllByAttributes(array('user_id' => $id)); $myPublicCams = $public; $mySharedCams = $shared; $allMyCams = array(); foreach ($myCams as $key => $cam) { $allMyCams[$cam->id] = $cam; } foreach ($myPublicCams as $key => $cam) { if (isset($cam->cam)) { $allMyCams[$cam->id] = $cam->cam; } else { $allMyCams[$cam->id] = $cam; } } foreach ($mySharedCams as $key => $cam) { $allMyCams[$cam->cam_id] = $cam->cam; } return $allMyCams; }
protected function setUp() { $this->client = Shared::Client(); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The locale `doesntExist` for region `us` is not supported. */ function testInvalidLocale() { $client = Shared::Client(); $client->setRegion('us', 'doesntExist'); }
} } } else { if ($got['status'] == 'created') { $ret = $this->send($activity, $got, $user); if (is_error($ret)) { exit('红包发放失败, 你可以在活动结束之前重新领取. 活动结束后无法领取, 请注意'); exit($ret['message']); } exit('success'); } } } if ($activity['type'] == 'shared') { require_once MB_ROOT . '/source/Shared.class.php'; $s = new Shared($activity); $count = $s->helpsCount($user['uid']); if ($count < $activity['tag']['helps']) { exit('还没达到领取礼品的条件'); } $got = $a->getRecord($user['uid'], $activity['actid']); if (empty($got)) { if (empty($error)) { $ret = $a->grap($user, $activity); if (is_error($ret)) { exit($ret['message']); } elseif ($ret['status'] == 'none') { exit('这一轮没有抢到红包, 请期待我们下一次活动'); } else { $got = $a->getRecord($user['uid'], $activity['actid']); $ret = $this->send($activity, $got, $user);
private function compileCams($cam) { $camName = explode('_', $cam); $camName = $this->double ? Shared::model()->findByPK($camName[1])->cam : Cams::model()->findByPK(Cams::model()->getRealId($camName[1])); if (!$camName) { throw new CHttpException(404, Yii::t('errors', 'There is no such cam')); } $this->buff[$cam] = $camName->getSessionId(); return $camName->name; }
<?php global $_W, $_GPC; $modulePublic = '../addons/microb_redpack/static/'; $footer_off = true; $_W['page']['title'] = $activity['title']; require_once MB_ROOT . '/source/Shared.class.php'; require_once MB_ROOT . '/source/Fans.class.php'; $f = new Fans(); $s = new Shared(); $uid = intval($_GPC['owner']); $owner = $f->getOne($uid); if (empty($owner)) { message('访问错误', $activity['guide'], 'info'); } $got = $s->getOneRecord($owner['uid']); $user = $this->auth(); $activity = $this->getActivity(true, array('user' => $user)); if (is_error($activity)) { message($activity['message']); } if ($owner['uid'] == $user['uid']) { header('Location: ' . $this->createMobileUrl('get')); exit; } $_share = array(); $_share['title'] = $activity['stitle']; $_share['desc'] = $activity['content']; $_share['imgUrl'] = tomedia($activity['image']); $_share['link'] = $_W['siteroot'] . 'app/' . substr(substr($this->createMobileUrl('entry', array('owner' => $user['uid'])), 2), 0, -39); if ($activity['type'] == 'direct') {
<?php define('DS', DIRECTORY_SEPARATOR); define('ROOT', dirname(dirname(__FILE__))); define('CURRENT_URL', $_SERVER['REQUEST_URI']); //当前URL const DEFAULT_LANGUAGE = 'Cn'; //默认语言(首字母大写) const DEFAULT_CONTROLLER = 'index'; //默认controller const DEFAULT_VIEW = 'index'; //默认View const DEFAULT_MODULE_NAME = 'home'; //默认 模块名称 const DEFAULT_LIMIT = 20; //默认数据查询数目 const DEFAULT_MAX_LIMIT = 1000; //默认数据最大返回数 require ROOT . DS . 'Common' . DS . 'functions.php'; require ROOT . DS . 'Library' . DS . 'Shared.class.php'; require ROOT . DS . 'Vendor' . DS . 'taobao' . DS . 'TopSdk.php'; require ROOT . DS . 'Vendor' . DS . 'taobao' . DS . 'top' . DS . 'TopClient.php'; Shared::start(); //运行框架
if (!empty($profile)) { exit('success'); } } if ($foo == 'history') { require_once MB_ROOT . '/source/Activity.class.php'; $id = $_GPC['actid']; $id = intval($id); $a = new Activity(); $activity = $a->getOne($id); if ($activity['type'] == 'game') { $filters = array(); $filters['owner'] = $user['uid']; $filters['activity'] = $activity['actid']; $records = $a->getRecords($filters); include $this->template('my-game'); } if ($activity['type'] == 'shared') { require_once MB_ROOT . '/source/Shared.class.php'; $s = new Shared($activity); $filters = array(); $filters['owner'] = $user['uid']; $ds = $s->getAllHelps($filters); if (!empty($ds)) { foreach ($ds as &$r) { $r['user'] = $f->getOne($r['helper']); } } include $this->template('my-shared'); } }
<?php global $_W, $_GPC; $modulePublic = '../addons/microb_redpack/static/'; $footer_off = true; $_W['page']['title'] = $activity['title']; $user = $this->auth(); $activity = $this->getActivity(true, array('user' => $user)); if (is_error($activity)) { message($activity['message']); } $_share = array(); $_share['title'] = $activity['stitle']; $_share['desc'] = $activity['content']; $_share['imgUrl'] = tomedia($activity['image']); $_share['link'] = $_W['siteroot'] . 'app/' . substr(substr($this->createMobileUrl('entry', array('owner' => $user['uid'])), 2), 0, -39); require_once MB_ROOT . '/source/Shared.class.php'; $s = new Shared(); $got = $s->getOneRecord($user['uid']); if ($activity['type'] == 'direct') { //直接发红包 } else { //分享集红包 $help = array(); $help['total'] = $activity['helps']; $help['already'] = $s->helpsCount($user['uid']); $help['ok'] = $help['already'] >= $activity['helps']; } include $this->template('get');
<?php Shared::Test();
/** * @expectedException WowApi\Exception\NotFoundException */ public function testSendToNonExistantResource() { $client = Shared::Client(); $response = $client->getRequest()->api('character/blank/blank'); $this->assertEquals(404, $response['headers']['http_code']); }
$got = $a->getRecord($user['uid'], $id); $filters = array(); $filters['activity'] = $id; $filters['status'] = 'complete'; $recents = $a->getRecords($filters, 1, 5, $total); if ($activity['type'] == 'direct') { //直接发红包 include $this->template('activity-direct'); } if ($activity['type'] == 'game') { //红包游戏 require_once MB_ROOT . '/source/Game.class.php'; $g = new Game(); $game = $activity['tag']; $game['quantity'] = $g->calcQuantity($activity['actid'], $user['uid']); $game['already'] = !empty($got); include $this->template('activity-game'); } if ($activity['type'] == 'shared') { $_share['link'] = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('shared', array('actid' => $activity['actid'], 'owner' => $user['uid'])), 2); //分享集红包 require_once MB_ROOT . '/source/Shared.class.php'; $s = new Shared($activity); $help = array(); $help['total'] = $activity['tag']['helps']; $help['already'] = $s->helpsCount($user['uid']); $help['isok'] = $help['already'] >= $help['total']; $activity['tag']['progress'] = htmlspecialchars_decode($activity['tag']['progress']); $activity['tag']['progress'] = str_replace('{left}', $help['total'] - $help['already'], $activity['tag']['progress']); include $this->template('activity-shared'); }