本文整理汇总了PHP中Website::find_by_code方法的典型用法代码示例。如果您正苦于以下问题:PHP Website::find_by_code方法的具体用法?PHP Website::find_by_code怎么用?PHP Website::find_by_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Website
的用法示例。
在下文中一共展示了Website::find_by_code方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gotosite
public function gotosite($site = null)
{
if ($this->GetData('site')) {
$site = $this->GetData('site');
}
$site = Website::find_by_code($site);
if (!$site) {
Site::Flash('error', 'Unable to find the site you want to go to');
Redirect('');
}
if ($user = Site::CurrentUser()) {
try {
$login = new Login();
$login->user_id = $user->id;
$login->user = $user;
$login->website_id = $site->id;
$login->website = $site;
$login->ip = Site::RemoteIP();
if ($login->save()) {
header("Location: {$login->url}");
die;
} else {
Site::Flash('error', 'Unable to redirect you');
Redirect('');
}
} catch (Error500 $e) {
$error = 'Error';
if ($e->getMessage()) {
$error .= ': ' . $e->getMessage();
}
Site::Flash('error', $error);
Redirect('');
}
} else {
if ($site) {
header("Location: {$site->url}");
die;
}
Site::Flash('error', 'Unable to go to site');
Redirect('');
}
}
示例2: xlogin
/**
* Retrieves a one time URL for a login into a website
*
* @arg string The RPCSession code
* @arg int The user ID to login
* @arg string The name of the site
* @arg string The IP of the user
*
* @param object $method The name of the RPC method
* @param object $args An array of arguements, listed above
* @return string The URL to use to access that site
* @throws RPCException
*/
public function xlogin($method, $args)
{
$this->auth($args[0]);
if (count($args) < 4) {
throw new RPCException('Invalid Arguements', 500);
}
$user = User::find_by_id($args[1]);
if (!$user) {
throw new RPCException('Unable to find user', 500);
}
$site = Website::find_by_code($args[2]);
if (!$site) {
throw new RPCException('Unable to find site', 500);
}
$destination = '';
if (isset($args[4])) {
$destination = $args[4];
}
$login = new Login();
$login->user_id = $user->id;
$login->user = $user;
$login->website_id = $site->id;
$login->website = $site;
$login->destination = $destination;
$login->ip = $args[3];
if ($login->save()) {
return $login->url;
} else {
throw new RPCException($login->errorString(), 500);
}
}