本文整理汇总了PHP中identity::lookup_user方法的典型用法代码示例。如果您正苦于以下问题:PHP identity::lookup_user方法的具体用法?PHP identity::lookup_user怎么用?PHP identity::lookup_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类identity
的用法示例。
在下文中一共展示了identity::lookup_user方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolve
static function resolve($id)
{
$user = identity::lookup_user($id);
if (!self::_can_view_profile_pages($user)) {
throw new Kohana_404_Exception();
}
return $user;
}
示例2: send
public function send($id)
{
access::verify_csrf();
$user = identity::lookup_user($id);
$form = user_profile::get_contact_form($user);
if ($form->validate()) {
Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error", "form" => (string) $form));
}
}
示例3: __get
/**
* @see ORM::__get()
*/
public function __get($column)
{
if ($column == "user") {
// This relationship depends on an outside module, which may not be present so handle
// failures gracefully.
try {
return identity::lookup_user($this->user_id);
} catch (Exception $e) {
Kohana_Log::add("alert", "Unable to load user with id {$this->user_id}");
return null;
}
} else {
return parent::__get($column);
}
}
示例4: send
public function send($id)
{
access::verify_csrf();
$user = identity::lookup_user($id);
if (!$this->_can_view_profile_pages($user)) {
throw new Kohana_404_Exception();
}
$form = user_profile::get_contact_form($user);
if ($form->validate()) {
Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
json::reply(array("result" => "success"));
} else {
json::reply(array("result" => "error", "html" => (string) $form));
}
}
示例5: set_active_user
static function set_active_user($access_token)
{
if (empty($access_token)) {
identity::set_active_user(identity::guest());
return;
}
$key = ORM::factory("user_access_token")->where("access_key", "=", $access_token)->find();
if (!$key->loaded()) {
throw new Rest_Exception("Forbidden", 403);
}
$user = identity::lookup_user($key->user_id);
if (empty($user)) {
throw new Rest_Exception("Forbidden", 403);
}
identity::set_active_user($user);
}
示例6: set_active_user
static function set_active_user($access_key)
{
if (empty($access_key)) {
if (module::get_var("rest", "allow_guest_access")) {
identity::set_active_user(identity::guest());
return;
} else {
throw new Rest_Exception("Forbidden", 403);
}
}
$key = ORM::factory("user_access_key")->where("access_key", "=", $access_key)->find();
if (!$key->loaded()) {
throw new Rest_Exception("Forbidden", 403);
}
$user = identity::lookup_user($key->user_id);
if (empty($user)) {
throw new Rest_Exception("Forbidden", 403);
}
identity::set_active_user($user);
}
示例7: thumb_info
static function thumb_info($theme, $item)
{
$results = "";
if ($item->view_count) {
$results .= "<li>";
$results .= t("Views: %view_count", array("view_count" => $item->view_count));
$results .= "</li>";
}
// rWatcher Edit: Display Tags on Thumbnails
if (module::is_active("tag")) {
$tags = ORM::factory("tag")->join("items_tags", "tags.id", "items_tags.tag_id")->where("items_tags.item_id", "=", $item->id)->find_all();
if (count($tags) > 0) {
$results .= "<li>";
$results .= t("Tags:") . " ";
$anchors = array();
foreach ($tags as $tag) {
$anchors[] = "<a href=" . $tag->url() . ">" . html::clean($tag->name) . "</a>";
}
$results .= join(", ", $anchors) . "</li>";
}
}
// rWatcher End Edit
if ($item->owner) {
// rWatcher Edit: Display profile instead of web site, if viewable.
$str_owner_url = $item->owner->url;
if (rwinfo_theme_Core::_can_view_profile_pages(identity::lookup_user($item->owner->id))) {
$str_owner_url = user_profile::url($item->owner->id);
}
// rWatcher End Edit
$results .= "<li>";
if ($str_owner_url) {
//rW Edit str_owner_url
$results .= t("By: <a href=\"%owner_url\">%owner_name</a>", array("owner_name" => $item->owner->display_name(), "owner_url" => $str_owner_url));
// rW Edit str_owner_url
} else {
$results .= t("By: %owner_name", array("owner_name" => $item->owner->display_name()));
}
$results .= "</li>";
}
return $results;
}
示例8: __get
/**
* @see ORM::__get()
*/
public function __get($column)
{
if ($column == "owner") {
// This relationship depends on an outside module, which may not be present so handle
// failures gracefully.
try {
return identity::lookup_user($this->owner_id);
} catch (Exception $e) {
return null;
}
} else {
return parent::__get($column);
}
}
示例9: i_can_edit_test
public function i_can_edit_test()
{
// Create a new user that belongs to no groups
$user = identity::create_user("access_test", "Access Test", "*****", "user@user.com");
foreach ($user->groups() as $group) {
$user->remove($group);
}
$user->save();
identity::set_active_user($user);
// This user can't edit anything
$root = item::root();
$this->assert_false(access::can("edit", $root));
// Now add them to a group that has edit permission
$group = identity::create_group("access_test");
$group->add($user);
$group->save();
access::allow($group, "edit", $root);
$user = identity::lookup_user($user->id);
// reload() does not flush related columns
identity::set_active_user($user);
// And verify that the user can edit.
$this->assert_true(access::can("edit", $root));
}
示例10: owner
public function owner()
{
return identity::lookup_user($this->owner_id);
}
示例11: author
function author()
{
return identity::lookup_user($this->author_id);
}
示例12: get
static function get($block_id, $theme)
{
$block = "";
switch ($block_id) {
case "rwinfo":
if ($theme->item()) {
// rWatcher Edit: Don't display on root album.
if ($theme->item->id == 1) {
return "";
}
// End rWatcher Edit
$block = new Block();
$block->css_id = "g-metadata";
$block->title = $theme->item()->is_album() ? t("Album info") : ($theme->item()->is_movie() ? t("Movie info") : t("Photo info"));
// rWatcher Edit: File Name change.
$block->content = new View("rwinfo_block.html");
if ($theme->item->title && module::get_var("rwinfo", "show_title")) {
//rWatcher Edit: rwinfo
$info["title"] = array("label" => t("Title:"), "value" => html::purify($theme->item->title));
}
if ($theme->item->description && module::get_var("rwinfo", "show_description")) {
//rWatcher Edit: rwinfo
$info["description"] = array("label" => t("Description:"), "value" => nl2br(html::purify($theme->item->description)));
}
if (!$theme->item->is_album() && module::get_var("rwinfo", "show_name")) {
//rWatcher Edit: rwinfo
$info["file_name"] = array("label" => t("File name:"), "value" => html::clean($theme->item->name));
}
// rWatcher Edit: Display file size
if (!$theme->item->is_album()) {
// Calculate file size.
$filesize_unit = array("B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
$item_filesize = filesize($theme->item->file_path());
$unit_counter = 0;
while ($item_filesize >= 1024) {
$item_filesize = $item_filesize / 1024;
$unit_counter++;
}
$item_filesize = number_format($item_filesize, 2) . " " . $filesize_unit[$unit_counter];
$info["file_size"] = array("label" => t("File size:"), "value" => $item_filesize);
}
// End rWatcher Edit
// rWatcher Edit: Remove Show Captured for everything -- Show created DATE for album, captured DATE/TIME for everything else.
//if ($theme->item->captured && module::get_var("info", "show_captured")) {
// $info["captured"] = array(
// "label" => t("Captured:"),
// "value" => gallery::date_time($theme->item->captured)
// );
//}
if ($theme->item->is_album() && $theme->item->created && module::get_var("rwinfo", "show_captured")) {
$info["captured"] = array("label" => t("Date:"), "value" => gallery::date($theme->item->created));
}
if (!$theme->item->is_album() && $theme->item->created && module::get_var("rwinfo", "show_captured")) {
$info["captured"] = array("label" => t("Date:"), "value" => gallery::date_time($theme->item->captured));
}
// End rWatcher Edit
if ($theme->item->owner && module::get_var("info", "show_owner")) {
$display_name = $theme->item->owner->display_name();
// rWatcher Edit: Display profile instead of web site, if viewable.
$str_owner_url = $theme->item->owner->url;
if (rwinfo_block_Core::_can_view_profile_pages(identity::lookup_user($theme->item->owner->id))) {
$str_owner_url = user_profile::url($theme->item->owner->id);
}
// rWatcher End Edit
if ($str_owner_url) {
//rW Edit $str_owner_url.
$info["owner"] = array("label" => t("Owner:"), "value" => html::anchor(html::clean($str_owner_url), html::clean($display_name)));
} else {
$info["owner"] = array("label" => t("Owner:"), "value" => html::clean($display_name));
}
}
if ($theme->item->width && $theme->item->height && module::get_var("info", "show_dimensions")) {
$info["size"] = array("label" => t("Dimensions:"), "value" => t("%width x %height px", array("width" => $theme->item->width, "height" => $theme->item->height)));
}
$block->content->metadata = $info;
module::event("info_block_get_metadata", $block, $theme->item);
}
break;
}
return $block;
}