Просмотр файла protected/components/User.php

Размер файла: 1.31Kb
<?php
/*
* System class
* @package: PerfCMS
*/
class User extends PerfUser
{
	/*
	 * @return value of row in profile
	 */
	public static function getProfileRow($rowName = '', $userId = false)
	{
		$db = PerfDb::init();
		if($rowName != '')
		{
			$rowName = Filters::input($rowName);
			if($userId == false)
			{
				if(parent::Id() != false)
				{
					return $db->query("SELECT `".$rowName."` FROM `users` WHERE `id` = '".parent::Id()."'")->fetchColumn();
				}
			}
			else
			{
				$userId = Filters::num($userId);
				if($db->query("SELECT * FROM `users` WHERE `id` = '".$userId."'")->rowCount() == 1)
				{
					return $db->query("SELECT `".$rowName."` FROM `users` WHERE `id` = '".$userId."'")->fetchColumn();
				}
			}
		}
	}
		
	/*
	 * @return value of row in settings
	 */
	public static function getSettingsRow($rowName = '', $userId = false)
	{
		if($rowName != '')
		{
			$rowName = Filters::input($rowName);
			if($userId == false)
			{
				$user = UserSettings::model()->findByPk(parent::Id());
				if($user === null)
				{
					return false;
				}
				else
				{
					return $user->$rowName;
				}
			}
			else
			{
				$userId = Filters::num($userId);
				$user = Settings::model()->findByPk($userId);
				if($user === null)
				{
					return false;
				}
				else
				{
					return $user->$rowName;
				}
			}
		}
	}
}