当前位置: 首页>>代码示例>>PHP>>正文


PHP UserModel::Construct方法代码示例

本文整理汇总了PHP中UserModel::Construct方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::Construct方法的具体用法?PHP UserModel::Construct怎么用?PHP UserModel::Construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModel的用法示例。


在下文中一共展示了UserModel::Construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ResolveProfileLinkById

 public static function ResolveProfileLinkById($userid)
 {
     $user = UserModel::Construct($userid);
     if (!$user) {
         return false;
     }
     return self::ResolveProfileLink($user);
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:8,代码来源:UserSocialHelper.class.php

示例2: smarty_function_user

/**
 * Convert a user id to a username and display that to the template.
 *
 * @todo Finish documentation of smarty_function_user
 *
 * @param array  $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param Smarty $smarty  Parent Smarty template object
 *
 * @return string
 * @throws SmartyException
 *
 * <h3>Usage Example</h3>
 *
 * <p>Typical usage for the Smarty user function</p>
 *
 * <code lang="text/html">
 * User Name: {user $userid}&lt;br/&gt;
 * </code>
 */
function smarty_function_user($params, $smarty){
	if(isset($params['user'])){
		$userid = $params['user'];
	}
	elseif(isset($params[0])){
		$userid = $params[0];
	}
	else{
		throw new SmartyException('Required parameter [user] not provided for user!');
	}

	/** @var UserModel $user */
	$user = UserModel::Construct($userid);

	if(!$user) return '';

	$username = $user->getDisplayName();
	return $username;
}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:38,代码来源:function.user.php

示例3: badge

 public function badge()
 {
     $view = $this->getView();
     $request = $this->getRequest();
     $uid = $request->getParameter('user');
     if ($uid instanceof UserModel) {
         $user = $uid;
         $uid = $user->get('id');
     } else {
         $user = UserModel::Construct($uid);
     }
     $direction = $request->getParameter('direction') ? $request->getParameter('direction') : 'horizontal';
     $orientation = $request->getParameter('orientation') ? $request->getParameter('orientation') : 'left';
     $view->assign('enableavatar', \ConfigHandler::Get('/user/enableavatar'));
     $view->assign('link', UserSocialHelper::ResolveProfileLink($user));
     $view->assign('user', $user);
     $view->assign('profiles', $user->get('external_profiles'));
     $view->assign('direction', $direction);
     $view->assign('orientation', $orientation);
     $view->assign('title', $request->getParameter('title'));
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:21,代码来源:UserProfileWidget.php

示例4: view

 /**
  * View a user's public profile
  */
 public function view()
 {
     $view = $this->getView();
     $request = $this->getPageRequest();
     $manager = \Core\user()->checkAccess('p:/user/users/manage');
     // Current user an admin?
     // First argument here will either be the username or user id.
     $arg1 = $request->getParameter(0);
     $user = UserModel::Construct($arg1);
     if (!($user && $user->exists())) {
         // Try by username instead.
         $match = UserUserConfigModel::Find(array('key' => 'username', 'value' => $arg1), 1);
         if (!$match) {
             return View::ERROR_NOTFOUND;
         }
         $user = UserModel::Construct($match->get('user_id'));
     }
     if (!$user) {
         return View::ERROR_NOTFOUND;
     }
     // If the UA requested the user by ID but the user has a username set, return a 404 as well.
     // This should help cut down on scanning attempts for userdata.
     if (is_numeric($arg1) && $user->get('username')) {
         return View::ERROR_NOTFOUND;
     }
     // Now see why username needs to not begin with a number? :p
     /** @var $user UserModel */
     // Only allow this if the user is either the same user or has the user manage permission.
     if ($user->get('id') == \Core\user()->get('id') || $manager) {
         $editor = true;
     } else {
         $editor = false;
     }
     $view->controls = ViewControls::DispatchModel($user);
     $view->title = $user->getDisplayName();
     $view->assign('user', $user);
     $view->assign('profiles', $user->get('external_profiles'));
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:41,代码来源:UserProfileController.php

示例5: render

	/**
	 * Render this form element and return the HTML content.
	 *
	 * @return string
	 */
	public function render() {
		$file = $this->getTemplateName();

		$tpl = \Core\Templates\Template::Factory($file);

		if($this->get('value')){
			/** @var UserModel $user */
			$user = UserModel::Construct($this->get('value'));
		}
		else{
			$user = null;
		}

		$tpl->assign('element', $this);
		$tpl->assign('can_lookup', \Core\user()->checkAccess('p:/user/search/autocomplete'));
		$tpl->assign('username', ($user ? $user->getDisplayName() : ''));

		return $tpl->fetch();
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:24,代码来源:FormUserInput.php

示例6: now

	public function now(){
		$request = $this->getPageRequest();
		$view = $this->getView();

		if(!$request->isJSON()) return View::ERROR_BADREQUEST;
		$view->contenttype = View::CTYPE_JSON;
		$view->mode = View::MODE_AJAX;
		$view->record = false;

		$limit = $this->_getQueryLimit();
		$duration = 60;
		// Use FindRaw because it's faster than using full Models for everything, especially when dealing with 20k + records.
		$listings = UserActivityModel::FindRaw('datetime >= ' . (Time::GetCurrent() - $duration), $limit, 'datetime DESC');


		$data = array();

		// Performance reports
		$data['information'] = array(
			'duration' => $duration,
		);
		$data['performance'] = array('get' => 0, 'post' => 0);
		$data['requests'] = array('get' => 0, 'post' => 0);
		$users = array();
		$bots = array();

		$guestname = \ConfigHandler::Get('/user/displayname/anonymous');

		foreach($listings as $log){
			if($log['type'] == 'GET'){
				$data['performance']['get'] += $log['processing_time'];
				$data['requests']['get']++;
			}
			elseif($log['type'] == 'POST'){
				$data['performance']['post'] += $log['processing_time'];
				$data['requests']['post']++;
			}

			$ua = new \Core\UserAgent($log['useragent']);
			
			if(class_exists('\\geocode\\IPLookup')){
				// If the geo library is available, use that to resolve the IP to something more meaningful than just a number.
				$lookup = new \geocode\IPLookup($log['ip_addr']);

				$file = \Core\Filestore\Factory::File('assets/images/iso-country-flags/' . strtolower($lookup->country) . '.png');
				
				if($lookup->province && $lookup->city){
					$title = $lookup->city . ', ' . $lookup->province . ', ' . $lookup->getCountryName();
				}
				elseif($lookup->province){
					$title = $lookup->province . ', ' . $lookup->getCountryName();
				}
				elseif($lookup->city){
					$title = $lookup->city . ' ' . $lookup->getCountryName();
				}
				else{
					$title =  $lookup->getCountryName();
				}

				$ip = '<span title="' . $title . '">';
				if($file->exists()){
					$ip .= '<img src="' . $file->getPreviewURL('20x20') . '" alt="' . $lookup->country . '"/> ';
				}
				$ip .= $log['ip_addr'];
				$ip .= '</span>';
			}
			else{
				$ip = $log['ip_addr'];
			}

			// Bots have their own data, because, well... they're bots.
			// Damn bots!
			if($ua->isBot()){
				if(!isset($bots[ $log['ip_addr'] ])){
					$bots[ $log['ip_addr'] ] = array(
						'ip'        => $ip,
						'useragent' => $log['useragent'],
						'lastpage'  => $log['request'],
						'status'    => $log['status'],
						//'type'      => $ua->,
						'browser'   => $ua->getAsHTML(),
						'count'     => 1,
					);
				}
				else{
					$bots[$log['ip_addr']]['count']++;
				}
			}
			// The user agent information I want to know on a per-user basis, not a per-click basis.
			else{
				if(!isset($users[ $log['session_id'] ])){
					$thisuser = UserModel::Construct($log['user_id']);

					$users[ $log['session_id'] ] = array(
						'session'   => $log['session_id'],
						'ip'        => $ip,
						'user_id'   => $log['user_id'],
						'username'  => ($thisuser ? $thisuser->getDisplayName() : $guestname),
						'useragent' => $log['useragent'],
						'lastpage'  => $log['request'],
//.........这里部分代码省略.........
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:101,代码来源:UserActivityController.php

示例7: view

 /**
  * View a specific cron execution and its details.
  */
 public function view()
 {
     $view = $this->getView();
     $request = $this->getPageRequest();
     $view->mode = View::MODE_PAGEORAJAX;
     if (!\Core\user()->checkAccess('p:/security/viewlog')) {
         return View::ERROR_ACCESSDENIED;
     }
     $logid = $request->getParameter(0);
     $log = SecurityLogModel::Construct($logid);
     if (!$log->exists()) {
         return View::ERROR_NOTFOUND;
     }
     if ($log->get('user_id')) {
         $userobject = UserModel::Construct($log->get('user_id'));
         $user = $userobject->getDisplayName();
     } else {
         $user = null;
     }
     if ($log->get('affected_user_id')) {
         $userobject = UserModel::Construct($log->get('affected_user_id'));
         $affected_user = $userobject->getDisplayName();
     } else {
         $affected_user = null;
     }
     $view->addBreadcrumb('Security Log', '/security/log');
     $view->title = 'Details';
     $view->assign('entry', $log);
     $view->assign('user', $user);
     $view->assign('affected_user', $affected_user);
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:34,代码来源:SecurityController.php

示例8: getDisplayName

	public function getDisplayName(){
		if($this->get('user_id')){
			$user = UserModel::Construct($this->get('user_id'));
			$uname = $user->getDisplayName();
		}
		else{
			$uname = ConfigHandler::Get('/user/displayname/anonymous');
		}

		return $uname;
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:11,代码来源:UserActivityModel.php

示例9: GetUserControlLinks

	/**
	 * Hook receiver for /core/controllinks/user/view
	 *
	 * @param int $userid
	 *
	 * @return array
	 */
	public static function GetUserControlLinks($userid){

		$enabled = \Core\User\Helper::GetEnabledAuthDrivers();
		if(!isset($enabled['datastore'])){
			// GPG isn't enabled at all, disable any control links from the system.
			return [];
		}

		if($userid instanceof UserModel){
			$user = $userid;
		}
		else{
			/** @var UserModel $user */
			$user = UserModel::Construct($userid);
		}

		if(!$user->exists()){
			// Invalid user.
			return [];
		}

		$isself = (\Core\user()->get('id') == $user->get('id'));
		$isadmin = \Core\user()->checkAccess('p:/user/users/manage');

		if(!($isself || $isadmin)){
			// Current user does not have access to manage the provided user's data.
			return [];
		}

		try{
			// If this throws an exception, then it's not enabled!
			$user->getAuthDriver('datastore');
		}
		catch(Exception $e){
			if($isself){
				return [
					[
						'link' => '/datastoreauth/forgotpassword',
						'title' => t('STRING_ENABLE_PASSWORD_LOGIN'),
						'icon' => 'key',
					]
				];
			}
		}

		$ret = [];
		$ret[] = [
			'link' => '/datastoreauth/password/' . $user->get('id'),
			'title' => t('STRING_CHANGE_PASSWORD'),
			'icon' => 'key',
		];

		if(sizeof($user->getEnabledAuthDrivers()) > 1){
			$ret[] = [
				'link' => '/datastoreauth/disable/' . $user->get('id'),
				'title' => t('STRING_DISABLE_PASSWORD_LOGIN'),
				'icon' => 'ban',
				'confirm' => 'Are you sure you want to disable password-based logins?  (They can be re-enabled if requested.)',
			];
		}


		return $ret;

	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:72,代码来源:DatastoreAuthController.php

示例10: foreach

 * Created by JetBrains PhpStorm.
 * User: powellc
 * Date: 1/17/13
 * Time: 10:20 PM
 * This is the upgrade file from 1.2.1 to 1.3.0.
 *
 * The blog system in 1.3.0 and later utilizes a dedicated Page entry for each blog entry.  This helps to have more
 * fine grain control over each entry's settings and data, as well as making use of the insertable system.
 */
// Create a page for each BlogArticle!
// Since this runs prior to the blog system being enabled, I need to manually include the model files.
require_once ROOT_PDIR . 'components/blog/models/BlogArticleModel.php';
require_once ROOT_PDIR . 'components/blog/models/BlogModel.php';
$articles = BlogArticleModel::Find();
foreach ($articles as $article) {
    /** @var $article BlogArticleModel */
    /** @var $blog BlogModel */
    $blog = $article->getLink('Blog');
    /** @var $page PageModel */
    $page = $article->getLink('Page');
    $page->setFromArray(array('title' => $article->get('title'), 'rewriteurl' => $blog->get('rewriteurl') . '/' . $article->get('id') . '-' . \Core\str_to_url($article->get('title')), 'parenturl' => $blog->get('baseurl'), 'fuzzy' => 0, 'admin' => 0));
    if ($article->get('authorid')) {
        $user = UserModel::Construct($article->get('authorid'));
        $page->setMeta('author', $user->getDisplayName());
        $page->setMeta('authorid', $user->get('id'));
    }
    $page->setMeta('description', $article->get('description'));
    $page->setMeta('keywords', $article->get('keywords'));
    $page->save();
}
// return
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:31,代码来源:121_to_130.php

示例11: implode

<?php

/**
 * Upgrade file for migrating user data from the user user configs to the new supplemental user table.
 */
// The migrations for source (user_user_config) to destination (user).
$migrations = ['first_name' => 'first_name', 'last_name' => 'last_name', 'phone' => 'phone', 'bio' => 'bio', 'username' => 'username'];
// Lookup each key and the corresponding user attached.
$sources = \Core\Datamodel\Dataset::Init()->select(['user_id', 'key', 'value'])->table('user_user_config')->where('key IN ' . implode(',', array_keys($migrations)))->executeAndGet();
$users = [];
foreach ($sources as $s) {
    if (!isset($users[$s['user_id']])) {
        $users[$s['user_id']] = UserModel::Construct($s['user_id']);
    }
    /** @var UserModel $u */
    $u = $users[$s['user_id']];
    $nk = $migrations[$s['key']];
    $nv = $s['value'];
    $u->set($nk, $nv);
}
// Now save each user loaded into the array.
foreach ($users as $u) {
    /** @var UserModel $u */
    $u->save();
}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:25,代码来源:123_user_config_migration.php

示例12: foreach

 *
 * @package Core
 */

// I'm using raw objects here because if there are a lot of user accounts in the system,
// creating a giant array of them all may take quite a bit of memory.
// FindRaw returns simply arrays, so less memory is required.
$userdat = UserModel::FindRaw();

foreach($userdat as $dat){
	/** @var array $dat */

	if($dat['avatar'] == ''){
		// Skip empty avatars, they don't get updated.
		continue;
	}

	if(strpos($dat['avatar'], 'public/') === 0){
		// Skip avatars that are already resolved.  They don't need to be updated.
		continue;
	}

	/** @var $u UserModel */
	$u = UserModel::Construct($dat['id']);
	// User avatars prior to 2.8.0 were saved in public/user.
	// After they are relocated to public/user/avatar, but with the Core relative path saved in the database, it'll be fine.
	// Saves me from having to copy all the files over to public/user/avatar!
	$u->set('avatar', 'public/user/' . $u->get('avatar'));
	$u->save();
}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:30,代码来源:270_to_280_user_avatar_paths.php

示例13: foreach

/**
 * Created by JetBrains PhpStorm.
 * User: powellc
 * Date: 1/17/13
 * Time: 10:20 PM
 * This is the upgrade file from 1.4.3 to 1.4.4
 *
 * Required because with the file input change in 2.6.0 returning core resolved paths,
 * the data in the database will contain that path now.
 */
$images = GalleryImageModel::Find();
foreach ($images as $i) {
    /** @var $i GalleryImageModel */
    // Just in case
    if (strpos($i->get('file'), 'public/') !== 0) {
        $i->set('file', 'public/galleryalbum/' . $i->get('file'));
        $i->save();
    }
    // Don't forget to copy over the meta data too!
    // This is because the gallery system will use the new version of metadata.
    $u = UserModel::Construct($i->get('uploaderid'));
    $helper = new \Core\Filestore\FileMetaHelper($i->getOriginalFile());
    $helper->setMeta('title', $i->get('title'));
    $helper->setMeta('keywords', explode(',', $i->get('keywords')));
    $helper->setMeta('description', $i->get('description'));
    $helper->setMeta('authorid', $i->get('uploaderid'));
    if ($u && $u instanceof User_Backend) {
        $helper->setMeta('author', $u->getDisplayName());
    }
}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:30,代码来源:143_to_144_filepathchange.php

示例14: getAuthor

 /**
  * Get the author of this article
  *
  * @return null|User_Backend
  */
 public function getAuthor()
 {
     $author = UserModel::Construct($this->get('authorid'));
     return $author;
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:10,代码来源:BlogArticleModel.php

示例15: _viewBlogArticle

 private function _viewBlogArticle(BlogModel $blog, BlogArticleModel $article)
 {
     $view = $this->getView();
     /** @var $page PageModel */
     $page = $article->getLink('Page');
     //$articles = $blog->getLink('BlogArticle');
     $manager = \Core\user()->checkAccess('p:/blog/manage_all');
     $editor = \Core\user()->checkAccess($blog->get('manage_articles_permission ')) || $manager;
     $author = UserModel::Construct($article->get('authorid'));
     //$authorid = $author->get('id');
     //var_dump($page->getMeta('keywords')); die();
     if (!$article->isPublished()) {
         // Is it actually not published, or just marked for a future publish date?
         if ($article->get('status') == 'published') {
             $publishdate = new CoreDateTime($article->get('published'));
             Core::SetMessage('Article is set to be published on ' . $publishdate->getFormatted('F jS, Y \\a\\t h:ia'), 'info');
         } else {
             Core::SetMessage('Article not published yet!', 'info');
         }
     }
     //$view->templatename = $page->get('page_template') ? $page->get('page_template') : 'pages/blog/article_view.tpl';
     $view->templatename = 'pages/blog/article_view.tpl';
     //$view->addBreadcrumb($blog->get('title'), $blog->get('rewriteurl'));
     $view->title = $article->get('title');
     $view->meta['title'] = $article->get('title');
     $view->updated = $article->get('updated');
     $view->canonicalurl = \Core\resolve_link($article->get('rewriteurl'));
     $view->meta['og:type'] = 'article';
     if ($article->get('image')) {
         $image = \Core\Filestore\Factory::File($article->get('image'));
         $view->meta['og:image'] = $image->getPreviewURL('200x200');
     }
     //if($author){
     //	/** @var $author User */
     //	//$view->meta['author'] = $author->getDisplayName();
     //	$view->meta['author'] = $author;
     //}
     $view->meta['description'] = $article->getTeaser();
     $view->assign('author', $author->exists() ? $author : null);
     $view->assign('article', $article);
     $view->assign('body', \Core\parse_html($article->get('body')));
     if ($editor) {
         $view->addControl('Edit Article', '/blog/article/update/' . $article->get('id'), 'edit');
         if ($article->get('status') == 'draft') {
             $view->addControl(['title' => 'Publish Article', 'link' => '/blog/article/publish/' . $blog->get('id') . '/' . $article->get('id'), 'icon' => 'arrow-up', 'confirm' => 'Publish article?']);
         }
         $view->addControl(array('title' => 'Delete Article', 'link' => '/blog/article/delete/' . $article->get('id'), 'icon' => 'remove', 'confirm' => 'Remove blog article?'));
     }
     // Add the extra view types for this page
     $view->addHead('<link rel="alternate" type="application/atom+xml" title="' . $page->get('title') . ' Atom Feed" href="' . \Core\resolve_link($blog->get('baseurl')) . '.atom"/>');
     $view->addHead('<link rel="alternate" type="application/rss+xml" title="' . $page->get('title') . ' RSS Feed" href="' . \Core\resolve_link($blog->get('baseurl')) . '.rss"/>');
     $view->addControl('RSS Feed', \Core\resolve_link($blog->get('baseurl')) . '.rss', 'rss');
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:53,代码来源:BlogController.php


注:本文中的UserModel::Construct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。