本文整理汇总了PHP中BOL_UserService类的典型用法代码示例。如果您正苦于以下问题:PHP BOL_UserService类的具体用法?PHP BOL_UserService怎么用?PHP BOL_UserService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BOL_UserService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* @see OW_AuthAdapter::authenticate()
*
* @return OW_AuthResult
*/
function authenticate()
{
$user = $this->userService->findUserForStandardAuth($this->identity);
$language = OW::getLanguage();
if ($user === null) {
return new OW_AuthResult(OW_AuthResult::FAILURE_IDENTITY_NOT_FOUND, null, array($language->text('base', 'auth_identity_not_found_error_message')));
}
if ($user->getPassword() !== BOL_UserService::getInstance()->hashPassword($this->password)) {
return new OW_AuthResult(OW_AuthResult::FAILURE_PASSWORD_INVALID, null, array($language->text('base', 'auth_invlid_password_error_message')));
}
return new OW_AuthResult(OW_AuthResult::SUCCESS, $user->getId(), array($language->text('base', 'auth_success_message')));
}
示例2: updateRate
public function updateRate()
{
if (empty($_POST['entityId']) || empty($_POST['entityType']) || empty($_POST['rate']) || empty($_POST['ownerId'])) {
exit(json_encode(array('errorMessage' => 'Invalid request')));
}
$service = BOL_RateService::getInstance();
$entityId = (int) $_POST['entityId'];
$entityType = trim($_POST['entityType']);
$rate = (int) $_POST['rate'];
$ownerId = (int) $_POST['ownerId'];
$userId = OW::getUser()->getId();
if (!OW::getUser()->isAuthenticated()) {
exit(json_encode(array('errorMessage' => OW::getLanguage()->text('base', 'rate_cmp_auth_error_message'))));
}
if ($userId === $ownerId) {
exit(json_encode(array('errorMessage' => OW::getLanguage()->text('base', 'rate_cmp_owner_cant_rate_error_message'))));
}
if (false) {
//TODO add authorization error
exit(json_encode(array('errorMessage' => 'Auth error')));
}
if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $ownerId)) {
exit(json_encode(array('errorMessage' => OW::getLanguage()->text('base', 'user_block_message'))));
}
$rateItem = $service->findRate($entityId, $entityType, $userId);
if ($rateItem === null) {
$rateItem = new BOL_Rate();
$rateItem->setEntityId($entityId)->setEntityType($entityType)->setUserId($userId)->setActive(true);
}
$rateItem->setScore($rate)->setTimeStamp(time());
$service->saveRate($rateItem);
$totalScoreCmp = new BASE_CMP_TotalScore($entityId, $entityType);
exit(json_encode(array('totalScoreCmp' => $totalScoreCmp->render(), 'message' => OW::getLanguage()->text('base', 'rate_cmp_success_message'))));
}
示例3: index
/**
* Finance list page controller
*
* @param array $params
*/
public function index(array $params)
{
$service = BOL_BillingService::getInstance();
$lang = OW::getLanguage();
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$onPage = 20;
$list = $service->getFinanceList($page, $onPage);
$userIdList = array();
foreach ($list as $sale) {
if (isset($sale['userId']) && !in_array($sale['userId'], $userIdList)) {
array_push($userIdList, $sale['userId']);
}
}
$displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($userIdList);
$userNames = BOL_UserService::getInstance()->getUserNamesForList($userIdList);
$this->assign('list', $list);
$this->assign('displayNames', $displayNames);
$this->assign('userNames', $userNames);
$total = $service->countSales();
// Paging
$pages = (int) ceil($total / $onPage);
$paging = new BASE_CMP_Paging($page, $pages, 10);
$this->assign('paging', $paging->render());
$this->assign('total', $total);
$stats = $service->getTotalIncome();
$this->assign('stats', $stats);
OW::getDocument()->setHeading($lang->text('admin', 'page_title_finance'));
OW::getDocument()->setHeadingIconClass('ow_ic_app');
}
示例4: crop
/**
* Action cropping avatar
*/
public function crop()
{
$language = OW::getLanguage();
$avatarService = BOL_AvatarService::getInstance();
$userService = BOL_UserService::getInstance();
$userId = OW_Auth::getInstance()->getUserId();
$hasAvatar = $avatarService->userHasAvatar($userId);
$this->assign('hasAvatar', $hasAvatar);
if ($hasAvatar) {
$this->assign('avatar', $avatarService->getAvatarUrl($userId, 2));
$this->assign('original', $avatarService->getAvatarUrl($userId, 3));
} else {
$this->assign('default', $avatarService->getDefaultAvatarUrl(2));
}
$staticJsUrl = OW::getPluginManager()->getPlugin('base')->getStaticJsUrl();
$staticCssUrl = OW::getPluginManager()->getPlugin('base')->getStaticCssUrl();
OW::getDocument()->addScript($staticJsUrl . 'jquery.Jcrop.js');
OW::getDocument()->addStyleSheet($staticCssUrl . 'jquery.Jcrop.css');
OW::getDocument()->addScript($staticJsUrl . 'crop_avatar.js');
$objParams = array('ajaxResponder' => $this->ajaxResponder, 'previewSize' => 100);
$script = "\$(document).ready(function(){\n var crop = new cropAvatar( " . json_encode($objParams) . ");\n crop.initCrop();\n }); ";
OW::getDocument()->addOnloadScript($script);
$profileEditUrl = OW::getRouter()->urlForRoute('base_edit');
$js = new UTIL_JsGenerator();
$js->newVariable('profileEditUrl', $profileEditUrl);
$js->jQueryEvent('#button-profile-edit', 'click', 'window.location.href=profileEditUrl;');
OW::getDocument()->addOnloadScript($js);
}
示例5: __construct
public function __construct($users, $size, $layout)
{
parent::__construct();
$questionService = BOL_QuestionService::getInstance();
$userService = BOL_UserService::getInstance();
$this->uniqId = uniqid('ucl_');
$idList = $this->fetchIdList($users);
$qList = $questionService->getQuestionData($idList, array('sex', 'birthdate'));
$displayNames = $userService->getDisplayNamesForList($idList);
$urls = $userService->getUserUrlsForList($idList);
$tplData = array();
foreach ($idList as $userId) {
$tplData[$userId] = array();
$tplData[$userId]['displayName'] = empty($displayNames[$userId]) ? null : $displayNames[$userId];
$tplData[$userId]['url'] = empty($urls[$userId]) ? null : $urls[$userId];
$tplData[$userId]['sex'] = empty($qList[$userId]['sex']) || in_array($layout, array(3, 4)) ? null : strtolower(BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $qList[$userId]['sex']));
$tplData[$userId]['birthdate'] = null;
if (!empty($qList[$userId]['birthdate']) && in_array($layout, array(1, 3))) {
$date = UTIL_DateTime::parseDate($qList[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
$tplData[$userId]['birthdate'] = $age;
}
$avatar = BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
$tplData[$userId]['thumb'] = $avatar ? $avatar : BOL_AvatarService::getInstance()->getDefaultAvatarUrl(2);
}
$sizes = array('small' => 100, 'medium' => 150, 'big' => OW::getConfig()->getValue('base', 'avatar_big_size'));
$this->assign('list', $tplData);
$avatarSize = $sizes[$size];
$this->assign('size', $size);
$this->assign('uniqId', $this->uniqId);
OW::getDocument()->addStyleDeclaration('.uc-avatar-size { width: ' . $avatarSize . 'px; height: ' . ($avatarSize + $avatarSize / 10) . 'px; }');
OW::getDocument()->addStyleDeclaration('.uc-carousel-size { height: ' . ($avatarSize + 50) . 'px; }');
OW::getDocument()->addStyleDeclaration('.uc-shape-waterWheel .uc-carousel { width: ' . ($avatarSize + 20) . 'px; }');
}
示例6: __construct
public function __construct($userId, $idList)
{
parent::__construct();
if (!empty($userId) && !empty($idList)) {
$this->user = BOL_UserService::getInstance()->findUserById($userId);
$userService = BOL_UserService::getInstance();
$avatars = BOL_AvatarService::getInstance()->getAvatarsUrlList($idList, 2);
$sexValue = array();
$list = array();
foreach (BOL_QuestionValueDao::getInstance()->findQuestionValues('sex') as $sexDto) {
$sexValue[$sexDto->value] = BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $sexDto->value);
}
$userData = BOL_QuestionService::getInstance()->getQuestionData($idList, array('sex', 'birthdate', 'googlemap_location'));
foreach ($idList as $userId) {
$list[$userId]['userUrl'] = $userService->getUserUrl($userId);
$list[$userId]['displayName'] = $userService->getDisplayName($userId);
$list[$userId]['avatarUrl'] = $avatars[$userId];
$list[$userId]['activity'] = UTIL_DateTime::formatDate(BOL_UserService::getInstance()->findUserById($userId)->getActivityStamp());
if (!empty($userData[$userId]['birthdate'])) {
$date = UTIL_DateTime::parseDate($userData[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$list[$userId]['age'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
}
if (!empty($userData[$userId]['sex'])) {
$list[$userId]['sex'] = $sexValue[$userData[$userId]['sex']];
}
if (!empty($userData[$userId]['googlemap_location'])) {
$list[$userId]['googlemap_location'] = $userData[$userId]['googlemap_location']['address'];
}
}
$this->assign('userName', BOL_UserService::getInstance()->getDisplayName($this->user->id));
$this->assign('list', $list);
} else {
$this->setVisible(FALSE);
}
}
示例7: ajaxRsp
public function ajaxRsp()
{
if (!OW::getRequest()->isAjax()) {
throw new Redirect403Exception();
}
$response = array();
if (empty($_GET['userId']) || empty($_GET['command'])) {
echo json_encode($response);
exit;
}
$userId = (int) $_GET['userId'];
$command = $_GET['command'];
switch ($command) {
case "suspend":
BOL_UserService::getInstance()->suspend($userId);
$response["info"] = OW::getLanguage()->text('base', 'user_feedback_profile_suspended');
break;
case "unsuspend":
BOL_UserService::getInstance()->unsuspend($userId);
$response["info"] = OW::getLanguage()->text('base', 'user_feedback_profile_unsuspended');
break;
}
echo json_encode($response);
exit;
}
示例8: getMenu
public static function getMenu($activeListType)
{
$language = OW::getLanguage();
$menuArray = array(array('label' => $language->text('base', 'user_list_menu_item_latest'), 'url' => OW::getRouter()->urlForRoute('base_user_lists', array('list' => 'latest')), 'iconClass' => 'ow_ic_clock', 'key' => 'latest', 'order' => 1), array('label' => $language->text('base', 'user_list_menu_item_online'), 'url' => OW::getRouter()->urlForRoute('base_user_lists', array('list' => 'online')), 'iconClass' => 'ow_ic_push_pin', 'key' => 'online', 'order' => 3), array('label' => $language->text('base', 'user_search_menu_item_label'), 'url' => OW::getRouter()->urlForRoute('users-search'), 'iconClass' => 'ow_ic_lens', 'key' => 'search', 'order' => 4));
if (BOL_UserService::getInstance()->countFeatured() > 0) {
$menuArray[] = array('label' => $language->text('base', 'user_list_menu_item_featured'), 'url' => OW::getRouter()->urlForRoute('base_user_lists', array('list' => 'featured')), 'iconClass' => 'ow_ic_push_pin', 'key' => 'featured', 'order' => 2);
}
$event = new BASE_CLASS_EventCollector('base.add_user_list');
OW::getEventManager()->trigger($event);
$data = $event->getData();
if (!empty($data)) {
$menuArray = array_merge($menuArray, $data);
}
$menu = new BASE_CMP_ContentMenu();
foreach ($menuArray as $item) {
$menuItem = new BASE_MenuItem();
$menuItem->setLabel($item['label']);
$menuItem->setIconClass($item['iconClass']);
$menuItem->setUrl($item['url']);
$menuItem->setKey($item['key']);
$menuItem->setOrder(empty($item['order']) ? 999 : $item['order']);
$menu->addElement($menuItem);
if ($activeListType == $item['key']) {
$menuItem->setActive(true);
}
}
return $menu;
}
示例9: __construct
public function __construct($entityType, $entityId, $likes = null)
{
parent::__construct();
if ($likes === null) {
$likes = NEWSFEED_BOL_Service::getInstance()->findEntityLikes($entityType, $entityId);
}
$this->count = count($likes);
if ($this->count == 0) {
$this->setVisible(false);
return;
}
$userIds = array();
foreach ($likes as $like) {
$userIds[] = (int) $like->userId;
}
if ($this->count <= 3) {
$displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($userIds);
$urls = BOL_UserService::getInstance()->getUserUrlsForList($userIds);
$langVars = array();
foreach ($userIds as $i => $userId) {
$langVars['user' . ($i + 1)] = '<a href="' . $urls[$userId] . '">' . $displayNames[$userId] . '</a>';
}
$string = OW::getLanguage()->text('newsfeed', 'feed_likes_' . $this->count . '_label', $langVars);
} else {
$url = "javascript: OW.showUsers(" . json_encode($userIds) . ")";
$string = OW::getLanguage()->text('newsfeed', 'feed_likes_list_label', array('count' => $this->count, 'url' => $url));
}
$this->assign('string', $string);
}
示例10: index
public function index($params)
{
if (!OW::getUser()->isAuthenticated()) {
throw new AuthenticateException();
}
if (OW::getUser()->isAdmin()) {
throw new Redirect404Exception();
}
$language = OW::getLanguage();
$this->setPageHeading($language->text('base', 'delete_user_index'));
$userId = OW::getUser()->getId();
// echo '<pre>';
// echo $userId;
// print_r($_POST);
// echo '</pre>';
//die;
if (OW::getRequest()->isPost() && !OW::getRequest()->isAjax()) {
if (isset($_POST['delete_user_button'])) {
OW::getUser()->logout();
BOL_UserService::getInstance()->deleteUser($userId, true);
$this->redirect(OW::getRouter()->urlForRoute('base_index'));
}
if (isset($_POST['cansel_button'])) {
$this->redirect(OW::getRouter()->urlForRoute('base_edit'));
}
}
}
示例11: buildData
protected function buildData($userIds, $group = null, $ignoreUserIds = array())
{
if (empty($userIds)) {
return array();
}
$avatarData = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIds, true, true, true, false);
$infoList = $this->getInfoList($userIds);
$onlineList = BOL_UserService::getInstance()->findOnlineStatusForUserList($userIds);
$out = array();
foreach ($userIds as $userId) {
if (in_array($userId, $ignoreUserIds)) {
continue;
}
$data = array();
$data['id'] = $userId;
$data['url'] = $avatarData[$userId]['url'];
$data['avatar'] = $avatarData[$userId]['src'];
$data['text'] = $avatarData[$userId]['title'];
$data['info'] = '<span class="ow_live_on"></span>' . implode(' ', $infoList[$userId]);
$data['online'] = $onlineList[$userId];
$itemCmp = new MCOMPOSE_CMP_UserItem($data);
$item = array();
$item["id"] = self::ID_PREFIX . "_" . $userId;
$item["text"] = $data['text'];
$item['html'] = $itemCmp->render();
$item['url'] = $data['url'];
$item['count'] = null;
if (!empty($group)) {
$item['group'] = $group;
}
$out[self::ID_PREFIX . '_' . $userId] = $item;
}
return $out;
}
示例12: remove
public function remove()
{
if (!OW::getRequest()->isAjax()) {
exit(json_encode(array()));
}
$lang = OW::getLanguage();
if (!OW::getUser()->isAuthenticated()) {
exit(json_encode(array('result' => false, 'error' => $lang->text('ocsfavorites', 'signin_required'))));
}
if (!OW::getUser()->isAuthorized('ocsfavorites', 'add_to_favorites')) {
exit(json_encode(array()));
}
if (empty($_POST['favoriteId'])) {
exit(json_encode(array()));
}
$service = OCSFAVORITES_BOL_Service::getInstance();
$userId = OW::getUser()->getId();
$favoriteId = (int) $_POST['favoriteId'];
$user = BOL_UserService::getInstance()->findUserById($favoriteId);
if (!$user) {
exit(json_encode(array()));
}
$favorite = $service->isFavorite($userId, $favoriteId);
if (!$favorite) {
exit(json_encode(array()));
}
$service->deleteFavorite($userId, $favoriteId);
exit(json_encode(array('result' => true, 'msg' => $lang->text('ocsfavorites', 'favorite_removed'))));
}
示例13: getList
public function getList()
{
$users = null;
$count = null;
if ($this->friendsMode) {
$count = OW::getEventManager()->call('plugin.friends.count_friends', array('userId' => $this->userId));
$users = OW::getEventManager()->call('plugin.friends.get_friend_list', array('userId' => $this->userId, 'count' => 500));
}
$hideUsers = array();
if (!empty($this->entityId)) {
$sentNotifications = EQUESTIONS_BOL_NotificationService::getInstance()->findSentNotificationList($this->entityId, $this->userId, 'ask');
foreach ($sentNotifications as $notification) {
$hideUsers[] = $notification->userId;
}
}
if ($count === null) {
$count = BOL_UserService::getInstance()->count();
}
if ($users === null) {
$users = array();
$userDtos = BOL_UserService::getInstance()->findRecentlyActiveList(0, 500);
foreach ($userDtos as $u) {
if ($u->id != $this->userId) {
$users[] = $u->id;
}
}
}
$out = array();
foreach ($users as $user) {
if (!in_array($user, $hideUsers)) {
$out[] = $user;
}
}
return array('count' => $count - 1, 'idList' => $out);
}
示例14: __construct
public function __construct(BASE_CLASS_WidgetParameter $params)
{
parent::__construct();
/*if ( !GROUPS_BOL_Service::getInstance()->isCurrentUserCanViewList() )
{
$this->setVisible(false);
return;
}*/
$userId = $params->additionalParamList['entityId'];
$count = empty($params->customParamList['count']) ? 3 : (int) $params->customParamList['count'];
// privacy check
$viewerId = OW::getUser()->getId();
$ownerMode = $userId == $viewerId;
$modPermissions = OW::getUser()->isAuthorized('groups');
if (!$ownerMode && !$modPermissions) {
$privacyParams = array('action' => GROUPS_BOL_Service::PRIVACY_ACTION_VIEW_MY_GROUPS, 'ownerId' => $userId, 'viewerId' => $viewerId);
$event = new OW_Event('privacy_check_permission', $privacyParams);
try {
OW::getEventManager()->trigger($event);
} catch (RedirectException $e) {
$this->setVisible(false);
return;
}
}
$userName = BOL_UserService::getInstance()->findUserById($userId)->getUsername();
if (!$this->assignList($userId, $count)) {
$this->setVisible($params->customizeMode);
return;
}
$this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('groups', 'widget_user_groups_view_all'), 'href' => OW::getRouter()->urlForRoute('groups-user-groups', array('user' => $userName)))));
}
示例15: profile
public function profile($paramList)
{
$userService = BOL_UserService::getInstance();
/* @var $userDao BOL_User */
$userDto = $userService->findByUsername($paramList['username']);
if ($userDto === null) {
throw new Redirect404Exception();
}
if (!OW::getUser()->isAuthorized('base', 'view_profile')) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('base', 'view_profile');
$this->assign('permissionMessage', $status['msg']);
return;
}
$eventParams = array('action' => 'base_view_profile', 'ownerId' => $userDto->id, 'viewerId' => OW::getUser()->getId());
$displayName = BOL_UserService::getInstance()->getDisplayName($userDto->id);
try {
OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
} catch (RedirectException $ex) {
throw new RedirectException(OW::getRouter()->urlForRoute('base_user_privacy_no_permission', array('username' => $displayName)));
}
$this->setPageTitle(OW::getLanguage()->text('base', 'profile_view_title', array('username' => $displayName)));
$this->setPageHeading(OW::getLanguage()->text('base', 'profile_view_heading', array('username' => $displayName)));
$this->setPageHeadingIconClass('ow_ic_user');
$profileHeader = OW::getClassInstance("BASE_MCMP_ProfileHeader", $userDto->id);
$this->addComponent("header", $profileHeader);
//Profile Info
$displayNameQuestion = OW::getConfig()->getValue('base', 'display_name_question');
$profileInfo = OW::getClassInstance("BASE_MCMP_ProfileInfo", $userDto->id, false, array($displayNameQuestion, "birthdate"));
$this->addComponent("info", $profileInfo);
$this->addComponent('contentMenu', OW::getClassInstance("BASE_MCMP_ProfileContentMenu", $userDto->id));
$this->addComponent('about', OW::getClassInstance("BASE_MCMP_ProfileAbout", $userDto->id, 80));
$place = BOL_MobileWidgetService::PLACE_MOBILE_PROFILE;
$this->initDragAndDrop($place, $userDto->id);
}