本文整理汇总了PHP中Model_Users::current_user方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Users::current_user方法的具体用法?PHP Model_Users::current_user怎么用?PHP Model_Users::current_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Users
的用法示例。
在下文中一共展示了Model_Users::current_user方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: game
/**
*
* @param Ultimatum_Model_Ultplayergroupknowledge $pScan
* @return string
*/
public function game(Ultimatum_Model_Ultplayergroupknowledge $pScan)
{
$game = Zend_Registry::get('ultimatum_game');
if ($game) {
$user = Model_Users::current_user();
ob_start();
?>
<fieldset id="ultimatum_game">
<legend>Ultimatum</legend>
<b>Game:</b> <?php
echo $game;
?>
, turn <?php
echo $game->turn();
if ($user && $user->can('ultimatum_manage')) {
echo $this->view->zupallinkbutton("/ultimatum/game/nextturn/game/" . $game->identity(), 'Next Turn');
}
?>
<br />
<?php
echo $this->view->zupallinkbutton("/ultimatum/game/switch/", 'Stop Playing');
?>
</fieldset>
<?php
return ob_get_clean();
} else {
return '';
}
}
示例2: is_allowed
/**
*
* @param <type> $pResource
* @return <type>
*/
public function is_allowed($pResource, Model_Users $pUser = NULL)
{
if (!$pUser) {
$pUser = Model_Users::current_user();
}
return self::acl()->isAllowed($pUser ? $pUser->role : Model_Roles::ROLE_ANONYMOUS, $pResource);
}
示例3: preDispatch
/**
*
*/
public function preDispatch()
{
$u = Model_Users::current_user();
if (!$u || !$u->can('site_admin')) {
$param = array('error' => 'This area is reserved for administrators');
$this->_forward('insecure', 'error', 'administer', $param);
}
}
示例4: get_user
function get_user($pReload = FALSE)
{
if ($pReload || is_null($this->_user)) {
// process
$this->_user = Model_Users::current_user();
}
return $this->_user;
}
示例5: preDispatch
/**
*
*/
public function preDispatch()
{
$u = Model_Users::current_user();
if (!$u || !$u->can('ultimatum_manage')) {
$param = array('error' => 'This area is reserved for administrators');
return $this->_forward('insecure', 'error', 'administer', $param);
}
$this->_helper->layout->setLayout('admin');
parent::preDispatch();
}
示例6: user_active_player
/**
*
* @param Model_Users $pUser = NULL
* @return Ultimatum_Model_Ultplayers
*/
public static function user_active_player($pUser = NULL)
{
if ($pUser == NULL) {
if (!($pUser = Model_Users::current_user())) {
throw new Exception(__METHOD__ . ': no user logged in');
}
$pUser = $pUser->identity();
} elseif (!($pUser = self::_as($pUser, 'Model_Users', TRUE))) {
throw new Exception(__METHOD__ . ': bad user passed: ' . print_r($pUser, TRUE));
}
$params = array('user' => $pUser, 'active' => 1);
$game = self::getInstance()->findOne($params);
return $game;
}
示例7: run
/**
*
*/
public function run()
{
$user = Model_Users::current_user();
if ($user) {
$pi = Ultimatum_Model_Ultplayers::getInstance();
$params = array('user' => $user->identity(), 'active' => 1, 'status' => 'active');
$active_games = $pi->find($params, 'id DESC');
foreach ($active_games as $ag) {
$ag->active = FALSE;
$ag->save();
}
} else {
$this->view()->nouser = true;
}
return $this->forward('index');
}
示例8: zupalusermenu
public function zupalusermenu()
{
ob_start();
?>
<div id="user_menu">
<h1>User</h1>
<?php
$user_menu = array();
$ini = Administer_Model_Modules::getInstance()->get('default')->module_path('configuration/info.ini');
$user = Model_Users::current_user();
if ($user) {
echo '<span class="tagline">Viewing As ', $user->username, '</span>';
$pages = new Zend_Config_Ini($ini, 'user_menu_in');
} else {
$pages = new Zend_Config_Ini($ini, 'user_menu_anon');
}
echo $this->getView()->navigation()->menu()->renderMenu(new Zend_Navigation($pages));
?>
</div>
<?php
return ob_get_clean();
}
示例9: usergamesAction
/**
*
*/
public function usergamesAction()
{
$data = array();
$game = $this->_getParam('game', '');
$user = $this->_getParam('user');
if ($user) {
$user = Model_Users::getInstance()->get($user);
} else {
$user = Model_Users::current_user();
}
$params = array('user' => $user->identity());
$game_type = $game ? Game_Model_Gametypes::game_type($game) : NULL;
$user_sessions = Game_Model_Gamesessionplayers::getInstance()->find($prarams);
foreach ($user_sessions as $us) {
$session = $us->session();
if ($game_type && !$session->is_game_type($game_type)) {
continue;
}
$out[] = $session->toArray(TRUE);
}
$this->_store('id', $out, 'name');
}
示例10: nextturnAction
public function nextturnAction()
{
if (!$this->_prep()) {
$this->_forward('index', 'index', NULL, array('error' => 'problem loading game'));
}
$user = Model_Users::current_user();
if ($user && $user->can('ultimatum_manage')) {
$this->view->game->next_turn();
}
}
示例11: activate
public function activate($pFor_user = NULL)
{
$game_type = $this->game_type();
$gtid = $game_type->identity();
if ($pFor_user) {
$uid = Zupal_Domain_Abstract::_as($pFor_user, 'Model_Users', TRUE);
} elseif ($user = Model_Users::current_user()) {
$uid = $user->identity();
} else {
throw new Exception(__METHOD__ . ': no user present');
}
$params = array('game_type' => $gtid, 'user' => $uid);
$other_player_sessions = Game_Model_Gamesessionplayers::getInstance()->find($params);
foreach ($other_player_sessions as $other_player_session) {
if ($other_player_session->game_session == $this->identity()) {
$other_player_session->active = 1;
} else {
$other_player_session->active = 0;
}
$other_player_session->save();
}
/*
$bond = new Model_Zupalbonds();
if (!$pFor_user):
$pFor_user = Model_Users::current_user();
if (!$pFor_user):
throw new Exception(__METHOD__ . ': trying to bond missing user to session');
endif;
endif;
$bond->type = 'active';
$bond->set_to_atom($this);
$bond->set_from_atom($pFor_user);
$bond->set_bond_atom($this->game_type());
$params = array(
'from_atom' => $bond->from_atom()->get_atomic_id(),
'bond_atom' => $bond->to_atom()->get_atomic_id(),
'type' => 'active'
);
$other_bonds = $bond->find($params);
$other_bond = array_pop($other_bonds);
if (count($other_bonds)):
foreach($other_bonds as $extra_bond):
$extra_bond->delete();
endforeach;
endif;
// find an existing bond that is a syner-G game activation for this user.
if ($other_bond):
$other_bond->set_to_atom($this);
$other_bond->save();
else:
$bond->save();
endif;
*/
}
示例12: editmeexecuteAction
/**
* Note -- becuase the processing of the user data is inherently custom
* it takes place in manual form here, not via form.
*/
public function editmeexecuteAction()
{
$user = Model_Users::current_user();
if (!$user) {
throw new Exception("No user found");
}
extract($this->_getAllParams());
if ($username) {
$user->set_username($username);
}
if ($new_password) {
$user->set_password($password, $new_password, $new_password_2);
}
// note -- intentionally NOT saving email change!
$user->save();
$params = array('message' => 'Updated User Record');
$this->_forward('me', NULL, NULL, $params);
}