本文整理汇总了PHP中common_logged_in函数的典型用法代码示例。如果您正苦于以下问题:PHP common_logged_in函数的具体用法?PHP common_logged_in怎么用?PHP common_logged_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_logged_in函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onEndShowScripts
function onEndShowScripts($action)
{
if (common_logged_in()) {
$action->element('span', array('id' => 'autocomplete-api', 'data-url' => common_local_url('autocomplete')));
$action->script($this->path('js/autocomplete.go.js'));
}
}
示例2: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('all', array('nickname' => $user->nickname)));
return;
}
$idGroup = $this->trimmed('idGroup');
$token = $this->trimmed('token-' . $idGroup);
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
if ($this->trimmed('submit-auto') != null) {
$groupids = NotesPDF::getNoticeIDsInAGroupModeAuto($idGroup);
$notices = Notice::multiGet('id', $groupids)->fetchAll();
GenerarPDF::content($idGroup, $notices, 'Automáticos');
} else {
if ($this->trimmed('submit-custom') != null) {
$tag = $this->trimmed('combo-tag') == 'Todos' ? '%' : $this->trimmed('combo-tag');
$nick = $this->trimmed('combo-user') == 'Todos' ? '%' : $this->trimmed('combo-user');
$grade = $this->trimmed('combo-grade') == 'Todos' ? '%' : $this->trimmed('combo-grade');
$noticeIds = NotesPDF::getNoticesInModeCustom(array('idGroup' => $idGroup, 'tag' => $tag, 'nick' => $nick, 'grade' => $grade));
$notices = Notice::multiGet('id', $noticeIds)->fetchAll();
GenerarPDF::content($idGroup, $notices, 'Personalizados');
} else {
$this->showForm('Error al generar los apuntes. Inténtelo de nuevo en unos minutos.');
}
}
}
示例3: showResults
function showResults($q, $page)
{
$user_group = new User_group();
$user_group->limit(($page - 1) * GROUPS_PER_PAGE, GROUPS_PER_PAGE + 1);
$wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
foreach ($wheres as $where) {
$where_q = "{$where} like '%" . trim($user_group->escape($q), '\'') . '%\'';
$user_group->whereAdd($where_q, 'OR');
}
$cnt = $user_group->find();
if ($cnt > 0) {
$terms = preg_split('/[\\s,]+/', $q);
$results = new GroupSearchResults($user_group, $terms, $this);
$results->show();
$user_group->free();
$this->pagination($page > 1, $cnt > GROUPS_PER_PAGE, $page, 'groupsearch', array('q' => $q));
} else {
// TRANS: Text on page where groups can be searched if no results were found for a query.
$this->element('p', 'error', _('No results.'));
$this->searchSuggestions($q);
if (common_logged_in()) {
// TRANS: Additional text on page where groups can be searched if no results were found for a query for a logged in user.
// TRANS: This message contains Markdown links in the form [link text](link).
$message = _('If you cannot find the group you\'re looking for, you can [create it](%%action.newgroup%%) yourself.');
} else {
// TRANS: Additional text on page where groups can be searched if no results were found for a query for a not logged in user.
// TRANS: This message contains Markdown links in the form [link text](link).
$message = _('Why not [register an account](%%action.register%%) and [create the group](%%action.newgroup%%) yourself!');
}
$this->elementStart('div', 'guide');
$this->raw(common_markup_to_html($message));
$this->elementEnd('div');
$user_group->free();
}
}
示例4: handle
function handle($args)
{
parent::handle($args);
if (common_logged_in()) {
// TRANS: Client error displayed trying to recover password while already logged in.
$this->clientError(_('You are already logged in!'));
return;
} else {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($this->arg('recover')) {
$this->recoverPassword();
} else {
if ($this->arg('reset')) {
$this->resetPassword();
} else {
// TRANS: Client error displayed when unexpected data is posted in the password recovery form.
$this->clientError(_('Unexpected form submission.'));
}
}
} else {
if ($this->trimmed('code')) {
$this->checkCode();
} else {
$this->showForm();
}
}
}
}
示例5: handle
/**
* Handle request
*
* This is the main method for handling a request. Note that
* most preparation should be done in the prepare() method;
* by the time handle() is called the action should be
* more or less ready to go.
*
* @param array $args $_REQUEST args; handled in prepare()
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return;
}
if (!$this->user->hasRole('grader')) {
$this->clientError(_('Usted no tiene privilegios para visitar esta página.'));
return;
}
$groupid = $this->trimmed('groupid');
$delimiter = $this->trimmed('grade-export-delimiter');
$separator = $this->trimmed('grade-export-separator');
$arrayReport = Grades::getGradedNoticesAndUsersWithinGroup($groupid);
$nicksMembers = Grades::getMembersNicksExcludeGradersAndAdmin($groupid);
foreach ($nicksMembers as $nick) {
if (!array_key_exists($nick, $arrayReport)) {
$arrayReport[$nick] = 0;
}
}
$arrayFinal = array();
foreach ($arrayReport as $alumno => $puntuacion) {
$arrayFinal[] = array($alumno, number_format($puntuacion, 2));
}
$this->generarInformeCSV($arrayFinal, 'report_group_' . $groupid . '.csv', $separator, $delimiter);
}
示例6: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
function prepare($args)
{
if (!parent::prepare($args)) {
return false;
}
if (!common_logged_in()) {
// TRANS: Client error displayed trying to delete an application while not logged in.
$this->clientError(_('You must be logged in to delete an application.'));
return false;
}
$id = (int) $this->arg('id');
$this->app = Oauth_application::staticGet('id', $id);
if (empty($this->app)) {
// TRANS: Client error displayed trying to delete an application that does not exist.
$this->clientError(_('Application not found.'));
return false;
}
$cur = common_current_user();
if ($cur->id != $this->app->owner) {
// TRANS: Client error displayed trying to delete an application the current user does not own.
$this->clientError(_('You are not the owner of this application.'), 401);
return false;
}
return true;
}
示例7: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
$this->checkSessionToken();
if (!common_logged_in()) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->clientError(_('Not logged in.'));
} else {
// Redirect to login.
common_set_returnto($this->selfUrl());
$user = common_current_user();
if (Event::handle('RedirectToLogin', array($this, $user))) {
common_redirect(common_local_url('login'), 303);
}
}
return false;
}
$id = $this->trimmed('profileid');
if (!$id) {
$this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
$this->clientError(_('No profile with that ID.'));
return false;
}
return true;
}
示例8: prepare
/**
* Prepare for the action
*
* We check to see that the user is logged in, has
* authenticated in this session, and has the right
* to configure the site.
*
* @param array $args Array of arguments from Web driver
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
// User must be logged in.
if (!common_logged_in()) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
}
$user = common_current_user();
// ...because they're logged in
assert(!empty($user));
// It must be a "real" login, not saved cookie login
if (!common_is_real_login()) {
// Cookie theft is too easy; we require automatic
// logins to re-authenticate before admining the site
common_set_returnto($this->selfUrl());
if (Event::handle('RedirectToLogin', array($this, $user))) {
common_redirect(common_local_url('login'), 303);
}
}
// User must have the right to change admin settings
if (!$user->hasRight(Right::CONFIGURESITE)) {
// TRANS: Client error message thrown when a user tries to change admin settings but has no access rights.
$this->clientError(_('You cannot make changes to this site.'));
}
// This panel must be enabled
$name = $this->trimmed('action');
$name = mb_substr($name, 0, -10);
if (!self::canAdmin($name)) {
// TRANS: Client error message throw when a certain panel's settings cannot be changed.
$this->clientError(_('Changes to that panel are not allowed.'), 403);
}
return true;
}
示例9: prepare
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return false;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('网页错误,请返回重试
'));
return false;
}
$id = $this->trimmed('profile');
if (!$id) {
$this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
$this->clientError(_('No profile with that ID.'));
return false;
}
return true;
}
示例10: handle
/**
* Handle input, produce output
*
* Switches based on GET or POST method. On GET, shows a form
* for posting a notice. On POST, saves the results of that form.
*
* Results may be a full page, or just a single notice list item,
* depending on whether AJAX was requested.
*
* @param array $args $_REQUEST contents
*
* @return void
*/
function handle($args)
{
if (!common_logged_in()) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
} else {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// check for this before token since all POST and FILES data
// is losts when size is exceeded
if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) {
// TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
// TRANS: %s is the number of bytes of the CONTENT_LENGTH.
$msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
$this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
}
parent::handle($args);
$user = common_current_user();
$group = User_group::staticGet('id', $this->trimmed('groupid'));
$taskid = $this->trimmed('taskid');
try {
$this->saveNewNotice();
Task::completeTask($user->id, $taskid);
} catch (Exception $e) {
$this->ajaxErrorMsg($e->getMessage(), $taskid, $group);
return;
}
}
}
}
示例11: prepare
/**
* Take arguments for running
*
* This method is called first, and it lets the action class get
* all its arguments and validate them. It's also the time
* to fetch any relevant data from the database.
*
* Action classes should run parent::prepare($args) as the first
* line of this method to make sure the default argument-processing
* happens.
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
return;
} else {
if (!common_is_real_login()) {
// Cookie theft means that automatic logins can't
// change important settings or see private info, and
// _all_ our settings are important
common_set_returnto($this->selfUrl());
$user = common_current_user();
if (Event::handle('RedirectToLogin', array($this, $user))) {
common_redirect(common_local_url('login'), 303);
}
} else {
$this->user = common_current_user();
$sdate = !isset($_REQUEST['sdate']) ? new DateTime('first day of this month') : new DateTime($_REQUEST['sdate']);
$edate = !isset($_REQUEST['edate']) ? new DateTime('last day of this month') : new DateTime($_REQUEST['edate']);
// Custom date range
$this->sa = Social_analytics::init($this->user->id, $sdate, $edate);
}
}
return true;
}
示例12: prepare
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
common_set_returnto($_SERVER['REQUEST_URI']);
if (Event::handle('RedirectToLogin', array($this, null))) {
common_redirect(common_local_url('login'), 303);
}
}
$id = $this->trimmed('id');
if (!$id) {
$this->profile = false;
} else {
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
// TRANS: Client error displayed when referring to non-existing profile ID.
$this->clientError(_('No profile with that ID.'));
return false;
}
}
$current = common_current_user()->getProfile();
if ($this->profile && !$current->canTag($this->profile)) {
// TRANS: Client error displayed when trying to tag a user that cannot be tagged.
$this->clientError(_('You cannot tag this user.'));
}
return true;
}
示例13: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
$user = common_current_user();
// User must be logged in.
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
// ...because they're logged in
assert(!empty($user));
// It must be a "real" login, not saved cookie login
if (!common_is_real_login()) {
// Cookie theft is too easy; we require automatic
// logins to re-authenticate before admining the site
common_set_returnto($this->selfUrl());
if (Event::handle('RedirectToLogin', array($this, $user))) {
common_redirect(common_local_url('login'), 303);
}
}
// User must have the right to review flags
if (!$user->hasRight(UserFlagPlugin::REVIEWFLAGS)) {
$this->clientError(_('You cannot review profile flags.'));
return false;
}
$this->page = $this->trimmed('page');
if (empty($this->page)) {
$this->page = 1;
}
$this->profiles = $this->getProfiles();
return true;
}
示例14: prepare
/**
* Prepare to run
*/
function prepare($args)
{
parent::prepare($args);
if (!common_config('inboxes', 'enabled')) {
$this->serverError(_('Inboxes must be enabled for groups to work.'));
return false;
}
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to leave a group.'));
return false;
}
$nickname_arg = $this->trimmed('nickname');
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname);
common_redirect(common_local_url('leavegroup', $args), 301);
return false;
}
if (!$nickname) {
$this->clientError(_('No nickname.'), 404);
return false;
}
$this->group = User_group::staticGet('nickname', $nickname);
if (!$this->group) {
$this->clientError(_('No such group.'), 404);
return false;
}
$cur = common_current_user();
if (!$cur->isMember($this->group)) {
$this->clientError(_('You are not a member of that group.'), 403);
return false;
}
return true;
}
示例15: handle
/**
* Handle input, produce output
*
* Switches based on GET or POST method. On GET, shows a form
* for posting a notice. On POST, saves the results of that form.
*
* Results may be a full page, or just a single notice list item,
* depending on whether AJAX was requested.
*
* @param array $args $_REQUEST contents
*
* @return void
*/
function handle($args)
{
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
} else {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// check for this before token since all POST and FILES data
// is losts when size is exceeded
if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) {
$this->clientError(sprintf(_('The server was unable to handle ' . 'that much POST data (%s bytes) due to its current configuration.'), $_SERVER['CONTENT_LENGTH']));
}
parent::handle($args);
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. ' . 'Try again, please.'));
}
try {
$this->saveNewNotice();
} catch (Exception $e) {
$this->showForm($e->getMessage());
return;
}
} else {
$this->showForm();
}
}
}