本文整理汇总了PHP中UserService类的典型用法代码示例。如果您正苦于以下问题:PHP UserService类的具体用法?PHP UserService怎么用?PHP UserService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
return;
Star_Http_Response::setBrownerCache(600);
$user_service = new UserService();
$user_service->getUserByPage(1, 10);
/*
$this->openCache('', 0);
if ($this->isCache())
{
return $this->showCache();
}
*/
//$this->view->assign('title', 'Hello world!');
//$this->view->setJsConfig(array(
// 'files' => array('jquery')
//));
echo date('Y-m-d H:i:s');
//$str = "fjakldjflakg'ja'gjqpoigjq;k<>faf<a href=www.baidu.com>www.baidu.com</a>";
//echo Star_Filter::escape($str);
//$this->view->assign(array('title' => 'Hello world', 'data' => 'fadjfakl'));
//echo date('Y-m-d H:i:s', Star_Date::getLastWeek());
//echo "Hello world";
//$this->view->setNoRender();
//$this->render('hello');
}
示例2: activateAction
public function activateAction($id)
{
$user_service = new UserService();
$this->response->setNotRender(true);
$result = $user_service->activate($id);
echo $result;
}
示例3: testAsMember
public function testAsMember()
{
$userService = new UserService();
$_SESSION["accountType"] = UserService::$MEMBER;
$result = $userService->verifyAccessRight(UserService::$CONTRIBUTOR);
$this->assertEquals(false, $result);
}
示例4: initEmail
public function initEmail()
{
$userService = new \UserService();
$this->tempPass = $this->request->getVal('tempPass');
if (empty($this->tempPass)) {
$this->tempPass = $userService->resetPassword($this->targetUser);
}
}
示例5: get_exchange_record_all
public function get_exchange_record_all($next_id, $count)
{
$exch_list = $this->exch_table->get_all($next_id, $count);
$userSer = new UserService(NULL);
foreach ($exch_list as $exch) {
$user = $userSer->get_by_uuid($exch->user->uuid);
$exch->user = $user;
}
return $exch_list;
}
示例6: testUserCreate
public function testUserCreate()
{
$userProxy = test::double('User', ['save' => function () {
echo "MOCKED User->save() called\n";
}]);
$service = new UserService();
$user = $service->createUserByName('Zachary');
$this->assertEquals('Zachary', $user->getName());
$userProxy->verifyInvoked('save');
}
示例7: indexAction
public function indexAction()
{
//$user_service = new UserService();
$user_service = new UserService();
var_dump($user_service->getUserByPage(1, 1));
$this->view->assign('title', 'Hello world!');
$this->view->setJsConfig(array('files' => array('jquery')));
//$str = "fjakldjflakg'ja'gjqpoigjq;k<>faf<a href=www.baidu.com>www.baidu.com</a>";
//echo Star_Filter::escape($str);
//echo date('Y-m-d H:i:s', Star_Date::getLastWeek());
echo "Hello world";
}
示例8: register
/**
* Register services related to Users
*
* @param Application $app
*/
public function register(Application $app)
{
$app['user.mapper'] = $app->share(function ($app) {
return new UserMapper($app['db'], new UserEntity());
});
$app['user-token.mapper'] = $app->share(function ($app) {
return new TokenMapper($app['db'], new TokenEntity());
});
$app['user-role-pivot.mapper'] = $app->share(function ($app) {
return new UserRolePivotMapper($app['db']);
});
$app['user.service'] = $app->share(function ($app) {
$verifyRegistrationView = new VerifyRegistrationView($app['mustache']);
$verifyRegistrationView->setUrlGenerator($app['url_generator']);
$service = new UserService();
$service->setUserMapper($app['user.mapper'])->setTokenMapper($app['user-token.mapper'])->setEmailService($app['email.service'])->setVerifyRegistrationView($verifyRegistrationView);
return $service;
});
$app['role.service'] = $app->share(function ($app) {
return new RoleService($app['user-role-pivot.mapper']);
});
$app['user.validator'] = $app->share(function ($app) {
return new UserValidator($app['validator']);
});
$app['user-registration.validator'] = $app->share(function ($app) {
return new UserRegistrationValidator($app['validator']);
});
$app['user.controller'] = $app->share(function ($app) {
$controller = new UserController();
$controller->setUserService($app['user.service'])->setUserValidator($app['user.validator'])->setUserRegistrationValidator($app['user-registration.validator']);
return $controller;
});
$app['user.converter'] = $app->share(function ($app) {
return new UserConverter($app['user.mapper']);
});
$app['verify-registration.controller'] = $app->share(function ($app) {
$controller = new VerifyRegistrationController();
$controller->setUserService($app['user.service']);
return $controller;
});
$app['reset-password.controller'] = $app->share(function ($app) {
$resetPasswordView = new ResetPasswordView($app['mustache']);
$resetPasswordView->setUrlGenerator($app['url_generator']);
return new ResetPasswordController($app['user.service'], $app['email.service'], $resetPasswordView);
});
$app->match('/users', 'user.controller:rest')->method('HEAD|POST')->bind('user-collection');
$app->match('/user', 'user.controller:rest')->method('GET|PUT')->bind('user-entity-self');
$app->match('/users/{user}', 'user.controller:rest')->method('GET')->bind('user-entity')->assert('user', '\\d+')->convert('user', 'user.converter:getUser');
$app->match('/users/{id}/verify-registration', 'verify-registration.controller:rest')->method('POST')->bind('verify-registration');
$app->match('/user/reset-password', 'reset-password.controller:rest')->method('POST|PUT')->bind('reset-password');
$this->setFirewallsAndAccessRules($app);
}
示例9: build_table
private function build_table()
{
$table_model = new SQLHTMLTableModel(CalendarSetup::$calendar_events_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.title', 'common'), 'title'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('date', 'date-common'), 'start_date'), new HTMLTableColumn($this->lang['calendar.titles.repetition']), new HTMLTableColumn(LangLoader::get_message('status.approved', 'common'), 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('start_date', HTMLTableSortingRule::DESC));
$table = new HTMLTable($table_model);
$table_model->set_caption($this->lang['calendar.config.events.management']);
$table_model->add_permanent_filter('parent_id = 0');
$results = array();
$result = $table_model->get_sql_results('event
LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id');
foreach ($result as $row) {
$event = new CalendarEvent();
$event->set_properties($row);
$category = $event->get_content()->get_category();
$user = $event->get_content()->get_author_user();
$edit_link = new LinkHTMLElement(CalendarUrlBuilder::edit_event(!$event->get_parent_id() ? $event->get_id() : $event->get_parent_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
$delete_link = new LinkHTMLElement(CalendarUrlBuilder::delete_event($event->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => !$event->belongs_to_a_serie() ? 'delete-element' : ''), 'fa fa-delete');
$user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
$author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name();
$br = new BrHTMLElement();
$results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event->get_id(), $event->get_content()->get_rewrited_title()), $event->get_content()->get_title()), 'left'), new HTMLTableRowCell(new SpanHTMLElement($category->get_name(), array('style' => $category->get_id() != Category::ROOT_CATEGORY && $category->get_color() ? 'color:' . $category->get_color() : ''))), new HTMLTableRowCell($author), new HTMLTableRowCell(LangLoader::get_message('from_date', 'main') . ' ' . $event->get_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . $br->display() . LangLoader::get_message('to_date', 'main') . ' ' . $event->get_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($event->belongs_to_a_serie() ? $this->lang['calendar.labels.repeat.' . $event->get_content()->get_repeat_type()] . ' - ' . $event->get_content()->get_repeat_number() . ' ' . $this->lang['calendar.labels.repeat_times'] : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($event->get_content()->is_approved() ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
}
$table->set_rows($table_model->get_number_of_matching_rows(), $results);
$this->view->put('table', $table->display());
}
示例10: update_profile
/**
* 更新用户信息
*/
function update_profile()
{
$userId = $_SESSION['userId'];
$oldPassword = is_empty($_REQUEST['oldPassword']) ? null : $_REQUEST['oldPassword'];
$password = is_empty($_REQUEST['password']) ? null : $_REQUEST['password'];
$password2 = is_empty($_REQUEST['password2']) ? null : $_REQUEST['password2'];
$code = '0';
if ($_SESSION['userDetail']['user_password'] != md5($oldPassword)) {
$code = 'wrongOldPassword';
} else {
$userService = new UserService();
$userService->updatePassword($userId, md5($password));
}
$output = array('retCode' => $code);
echo get_json($output);
}
示例11: run
public function run()
{
$model = new User(User::SCENARIO_LOGIN);
// collect user input data
if (isset($_REQUEST['User'])) {
$model->attributes = $_REQUEST['User'];
// validate user input and redirect to previous page if valid
if ($model->validate()) {
$errorCode = UserService::login($model);
switch ($errorCode) {
case UserIdentity::ERROR_NONE:
$this->returnSuccess();
break;
case UserIdentity::ERROR_USERNAME_INVALID:
$model->addError('username', Yii::t('user', 'Username is not registered'));
break;
case UserIdentity::ERROR_PASSWORD_INVALID:
$model->addError('password', Yii::t('user', 'Password is not valid'));
break;
case UserIdentity::ERROR_UNKNOWN_IDENTITY:
$model->addError('username', Yii::t('user', 'Unkown identity'));
break;
}
}
}
$this->returnOrRenderView($model, 'login');
}
示例12: build_view
private function build_view($request)
{
$config = BugtrackerConfig::load();
$versions = $config->get_versions();
$display_versions = count($versions);
$stats_cache = BugtrackerStatsCache::load();
$bugs_number_per_version = $stats_cache->get_bugs_number_per_version_list();
$top_posters = $stats_cache->get_top_posters_list();
$this->view->put_all(array('C_BUGS' => $stats_cache->get_bugs_number('total'), 'C_FIXED_BUGS' => !empty($bugs_number_per_version), 'C_POSTERS' => !empty($top_posters), 'C_DISPLAY_VERSIONS' => $display_versions, 'C_DISPLAY_TOP_POSTERS' => $config->are_stats_top_posters_enabled(), 'C_ROADMAP_ENABLED' => $config->is_roadmap_enabled()));
foreach ($stats_cache->get_bugs_number_list() as $status => $bugs_number) {
if ($status != 'total') {
$this->view->assign_block_vars('status', array('NAME' => $this->lang['status.' . $status], 'NUMBER' => $bugs_number));
}
}
foreach ($bugs_number_per_version as $version_id => $bugs_number) {
$release_date = !empty($versions[$version_id]['release_date']) && is_numeric($versions[$version_id]['release_date']) ? new Date($versions[$version_id]['release_date'], Timezone::SERVER_TIMEZONE) : null;
$this->view->assign_block_vars('fixed_version', array('NAME' => stripslashes($versions[$version_id]['name']), 'RELEASE_DATE' => !empty($release_date) ? $release_date->format(Date::FORMAT_DAY_MONTH_YEAR) : $this->lang['notice.not_defined_e_date'], 'LINK_VERSION_ROADMAP' => BugtrackerUrlBuilder::roadmap($version_id, Url::encode_rewrite($versions[$version_id]['name']))->rel(), 'NUMBER' => $bugs_number['all']));
}
foreach ($top_posters as $id => $poster) {
if (isset($poster['user'])) {
$author_group_color = User::get_group_color($poster['user']->get_groups(), $poster['user']->get_level(), true);
$this->view->assign_block_vars('top_poster', array('C_AUTHOR_GROUP_COLOR' => !empty($author_group_color), 'ID' => $id, 'AUTHOR' => $poster['user']->get_display_name(), 'AUTHOR_LEVEL_CLASS' => UserService::get_level_class($poster['user']->get_level()), 'AUTHOR_GROUP_COLOR' => $author_group_color, 'LINK_AUTHOR_PROFILE' => UserUrlBuilder::profile($poster['user']->get_id())->rel(), 'USER_BUGS' => $poster['bugs_number']));
}
}
return $this->view;
}
示例13: execute
public function execute(HTTPRequestCustom $request)
{
$lang = LangLoader::get('common');
$is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
$number_admins = UserService::count_admin_members();
$suggestions = array();
try {
$result = PersistenceContext::get_querier()->select("SELECT user_id, display_name, level, groups FROM " . DB_TABLE_MEMBER . " WHERE display_name LIKE '" . str_replace('*', '%', $request->get_value('value', '')) . "%'");
while ($row = $result->fetch()) {
$user_group_color = User::get_group_color($row['groups'], $row['level']);
$suggestion = '';
if ($is_admin) {
$edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($row['user_id']), '', array('title' => $lang['edit']), 'fa fa-edit');
if ($row['level'] != User::ADMIN_LEVEL || $row['level'] == User::ADMIN_LEVEL && $number_admins > 1) {
$delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($row['user_id']), '', array('title' => $lang['delete'], 'data-confirmation' => 'delete-element'), 'fa fa-delete');
} else {
$delete_link = new LinkHTMLElement('', '', array('title' => $lang['delete'], 'onclick' => 'return false;'), 'fa fa-delete icon-disabled');
}
$suggestion .= $edit_link->display() . ' ' . $delete_link->display() . ' ';
}
$profile_link = new LinkHTMLElement(UserUrlBuilder::profile($row['user_id'])->rel(), $row['display_name'], array('style' => !empty($user_group_color) ? 'color:' . $user_group_color : ''), UserService::get_level_class($row['level']));
$suggestion .= $profile_link->display();
$suggestions[] = $suggestion;
}
$result->dispose();
} catch (Exception $e) {
}
return new JSONResponse(array('suggestions' => $suggestions));
}
示例14: build_view
private function build_view($group_id)
{
if (!empty($group_id)) {
$group = $this->groups_cache->get_group($group_id);
$this->view->put_all(array('C_ADMIN' => AppContext::get_current_user()->check_level(User::ADMIN_LEVEL), 'U_ADMIN_GROUPS' => TPL_PATH_TO_ROOT . '/admin/admin_groups.php?id=' . $group_id, 'GROUP_NAME' => $group['name']));
} else {
$this->view->put_all(array('GROUP_NAME' => $this->lang['groups']));
}
$user_accounts_config = UserAccountsConfig::load();
$number_member = 0;
foreach ($this->get_members_group($group_id) as $user_id) {
if (!empty($user_id)) {
$user = PersistenceContext::get_querier()->select('SELECT
member.display_name, member.level, member.groups, member.warning_percentage, member.delay_banned, ext_field.user_avatar
FROM ' . DB_TABLE_MEMBER . ' member
LEFT JOIN ' . DB_TABLE_MEMBER_EXTENDED_FIELDS . ' ext_field ON ext_field.user_id = member.user_id
WHERE member.user_id = :user_id
', array('user_id' => $user_id))->fetch();
if (!empty($user)) {
//Avatar
$user_avatar = !empty($user['user_avatar']) ? Url::to_rel($user['user_avatar']) : ($user_accounts_config->is_default_avatar_enabled() ? Url::to_rel('/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name()) : '');
$group_color = User::get_group_color($user['groups'], $user['level']);
$this->view->assign_block_vars('members_list', array('C_AVATAR' => $user['user_avatar'] || $user_accounts_config->is_default_avatar_enabled(), 'C_GROUP_COLOR' => !empty($group_color), 'PSEUDO' => $user['display_name'], 'LEVEL' => $user['warning_percentage'] < '100' || time() - $user['delay_banned'] < 0 ? UserService::get_level_lang($user['level']) : $this->lang['banned'], 'LEVEL_CLASS' => UserService::get_level_class($user['level']), 'GROUP_COLOR' => $group_color, 'U_PROFILE' => UserUrlBuilder::profile($user_id)->rel(), 'U_AVATAR' => $user_avatar));
$number_member++;
}
}
}
$this->view->put_all(array('C_NOT_MEMBERS' => $number_member == 0, 'SELECT_GROUP' => $this->build_form($group_id)->display()));
}
示例15: build_table
private function build_table()
{
$table_model = new SQLHTMLTableModel(DownloadSetup::$download_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.name', 'common'), 'name'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'creation_date'), new HTMLTableColumn(LangLoader::get_message('status', 'common'), 'approbation_type'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC));
$table = new HTMLTable($table_model);
$table_model->set_caption($this->lang['download.management']);
$results = array();
$result = $table_model->get_sql_results('download
LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\'
LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . '
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id', array('*', 'download.id'));
foreach ($result as $row) {
$downloadfile = new DownloadFile();
$downloadfile->set_properties($row);
$category = $downloadfile->get_category();
$user = $downloadfile->get_author_user();
$edit_link = new LinkHTMLElement(DownloadUrlBuilder::edit($downloadfile->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
$delete_link = new LinkHTMLElement(DownloadUrlBuilder::delete($downloadfile->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
$user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
$author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name();
$results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $downloadfile->get_id(), $downloadfile->get_rewrited_name()), $downloadfile->get_name()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($downloadfile->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($downloadfile->get_status()), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
}
$table->set_rows($table_model->get_number_of_matching_rows(), $results);
$this->view->put('table', $table->display());
}