Difference between revisions of "API:EPrints/DataObj/User"

From EPrints Documentation
Jump to: navigation, search
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
<!-- Pod2Wiki=_preamble_  
 
<!-- Pod2Wiki=_preamble_  
This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost.
+
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
  -->{{API:Source|file=EPrints/DataObj/User.pm|package_name=EPrints::DataObj::User}}[[Category:API|User]]<!-- End of Pod2Wiki -->
+
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=perl_lib/EPrints/DataObj/User.pm|package_name=EPrints::DataObj::User}}[[Category:API|USER]][[Category:API:EPrints/DataObj|USER]][[Category:API:EPrints/DataObj/User|USER]]<div><!-- Edit below this comment -->
<!-- Pod2Wiki=head_name -->'''EPrints::DataObj::User''' - Class representing a single user.
 
__TOC__
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_description -->=DESCRIPTION=
 
This class represents a single eprint user record and the metadata associated with it.
 
EPrints::DataObj::User is a subclass of EPrints::DataObj with the followingmetadata fields (plus those defined in ArchiveMetadataFieldsConfig:
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_system_metadata -->=SYSTEM METADATA=
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_userid -->==userid==
 
  
  userid (int)
 
  
The unique ID number of this user record. Unique within the current repository.
+
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
<!-- End of Pod2Wiki -->
+
==NAME==
<!-- Pod2Wiki=item_rev_number -->==rev_number==
+
'''EPrints::DataObj::User''' - Class representing a single user.
  
  rev_number (int)
+
<!-- Edit below this comment -->
  
The revision number of this record. Each time it is changed the revisionnumber is increased. This is not currently used for anything but it maybe used for logging later.
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_username -->==username==
 
  
  username (text)
+
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_description -->
 +
==DESCRIPTION==
 +
This class represents a single eprint user record and the metadata  associated with it.
  
The username of this user. Used for logging into the system. Unique withinthis repository.
+
EPrints::DataObj::User is a subclass of EPrints::DataObj with the following metadata fields (plus those defined in ArchiveMetadataFieldsConfig:
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_password -->==password==
 
  
  password (secret)
+
<!-- Edit below this comment -->
  
The password of this user encoded with crypt. This may be ignored if therepository is using an alternate authentication system, eg. LDAP.
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_usertype -->==usertype==
 
  
  usertype (namedset)
+
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_system_metadata -->
 +
==SYSTEM METADATA==
 +
* userid (int)
 +
: The unique ID number of this user record. Unique within the current repository.
  
The type of this user. The options are configured in metadata-phrases.xml.
+
* rev_number (int)
<!-- End of Pod2Wiki -->
+
: The revision number of this record. Each time it is changed the revision number is increased. This is not currently used for anything but it may be used for logging later.
<!-- Pod2Wiki=item_newemail -->==newemail==
 
  
  newemail (email)
+
* username (text)
 +
: The username of this user. Used for logging into the system. Unique within this repository.
  
Used to store a new but as yet unconfirmed email address.
+
* password (secret)
<!-- End of Pod2Wiki -->
+
: The crypted password for this user as generated by [[API:EPrints/Utils#crypt|EPrints::Utils/crypt]]. This may be ignored if for example LDAP authentication is being used.
<!-- Pod2Wiki=item_newpassword -->==newpassword==
 
  
  newpassword (secret)
+
* usertype (namedset)
 +
: The type of this user. The options are configured in metadata-phrases.xml.
  
Used to store a new but as yet unconfirmed password.
+
* newemail (email)
<!-- End of Pod2Wiki -->
+
: Used to store a new but as yet unconfirmed email address.
<!-- Pod2Wiki=item_pin -->==pin==
 
  
  pin (text)
+
* newpassword (secret)
 +
: Used to store a new but as yet unconfirmed password.
  
A code required to confirm a new username or password. This code is emailedto the user to confirm they are who they say they are.
+
* pin (text)
<!-- End of Pod2Wiki -->
+
: A code required to confirm a new username or password. This code is emailed to the user to confirm they are who they say they are.
<!-- Pod2Wiki=item_pinsettime -->==pinsettime==
 
  
  pinsettime (int)
+
* pinsettime (int)
 +
: When the pin code was set, so we can make it time out.
  
When the pin code was set, so we can make it time out.
+
* joined (time)
<!-- End of Pod2Wiki -->
+
: The date and time that the user account was created. Before EPrints 2.4 this was a date field so users created before the upgrade will appear to have been  created at midnight.
<!-- Pod2Wiki=item_joined -->==joined==
 
  
  joined (time)
+
* email (email)
 +
: The email address of this user. Unique within the repository.
  
The date and time that the user account was created. Before EPrints 2.4 thiswas a date field so users created before the upgrade will appear to have been created at midnight.
+
* lang (namedset)
<!-- End of Pod2Wiki -->
+
: The ID of the prefered language of this user. Only really used in multilingual repositories.
<!-- Pod2Wiki=item_email -->==email==
 
  
  email (email)
+
* editperms (search, multiple)
 +
: This field is used to filter what eprints a staff member can approve and  modify. If it's unset then they can modify any (given the correct privs. but if it is set then an eprint must match at least one of the searches to be within their scope.
  
The email address of this user. Unique within the repository.  
+
* frequency (set)
<!-- End of Pod2Wiki -->
+
: Only relevant to staff accounts. Is the frequency they want to be mailed  about eprints matching their scope that are in editorial review. never,  daily, weekly or monthly.
<!-- Pod2Wiki=item_lang -->==lang==
 
  
  lang (namedset)  
+
* mailempty (boolean)
 +
: Only relevant to staff accounts. If set to true then emails are sent even if there are no items matching the scope.
  
The ID of the prefered language of this user. Only really used in multilingualrepositories.
+
* preference (compound)
<!-- End of Pod2Wiki -->
+
: User preferences which need to be persistent (simple key-value pairs).
<!-- Pod2Wiki=item_editperms -->==editperms==
 
  
  editperms (search, multiple)
+
<!-- Edit below this comment -->
  
This field is used to filter what eprints a staff member can approve and modify. If it's unset then they can modify any (given the correct privs. butif it is set then an eprint must match at least one of the searches to bewithin their scope.
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_frequency -->==frequency==
 
  
  frequency (set)
+
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_methods -->
 +
==METHODS==
 +
<!-- Pod2Wiki=head_get_system_field_info -->
 +
===get_system_field_info===
  
Only relevant to staff accounts. Is the frequency they want to be mailed about eprints matching their scope that are in editorial review. never, daily, weekly or monthly.
+
<source lang="perl">$field_info = EPrints::DataObj::User->get_system_field_info
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_mailempty -->==mailempty==
 
  
  mailempty (boolean)
+
</source>
 +
Return an array describing the system metadata of the this  dataset.
  
Only relevant to staff accounts. If set to true then emails are senteven if there are no items matching the scope.
+
<!-- Edit below this comment -->
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_methods -->=METHODS=
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_system_field_info -->==get_system_field_info==
 
  
  $field_info = EPrints::DataObj::User-&gt;get_system_field_info
 
  
Return an array describing the system metadata of the this dataset.
+
<!-- Pod2Wiki= -->
<!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki=head_new -->
<!-- Pod2Wiki=item_new -->==new==
+
===new===
  
  $user = EPrints::DataObj::User-&gt;new( $session, $userid )
+
<source lang="perl">$user = EPrints::DataObj::User->new( $session, $userid )
  
Load the user with the ID of $userid from the database and returnit as an EPrints::DataObj::User object.
+
</source>
<!-- End of Pod2Wiki -->
+
Load the user with the ID of $userid from the database and return it as an EPrints::DataObj::User object.
<!-- Pod2Wiki=item_new_from_data -->==new_from_data==
 
  
  $user = EPrints::DataObj::User-&gt;new_from_data( $session, $data )
+
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_new_from_data -->
 +
===new_from_data===
 +
 
 +
<source lang="perl">$user = EPrints::DataObj::User->new_from_data( $session, $data )
 +
 
 +
</source>
 +
Construct a new EPrints::DataObj::User object based on the $data hash  reference of metadata.
  
Construct a new EPrints::DataObj::User object based on the $data hash reference of metadata.
 
 
Used to create an object from the data retrieved from the database.
 
Used to create an object from the data retrieved from the database.
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_dataset_id -->==get_dataset_id==
 
  
  $dataset = EPrints::DataObj::User-&gt;get_dataset_id
+
<!-- Edit below this comment -->
  
 +
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_get_dataset_id -->
 +
===get_dataset_id===
 +
 +
<source lang="perl">$dataset = EPrints::DataObj::User->get_dataset_id
 +
 +
</source>
 
Returns the id of the [[API:EPrints/DataSet|EPrints::DataSet]] object to which this record belongs.
 
Returns the id of the [[API:EPrints/DataSet|EPrints::DataSet]] object to which this record belongs.
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_defaults -->==get_defaults==
 
  
  $defaults = EPrints::DataObj::User-&gt;get_defaults( $session, $data )
+
<!-- Edit below this comment -->
  
 +
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_get_defaults -->
 +
===get_defaults===
 +
 +
<source lang="perl">$defaults = EPrints::DataObj::User->get_defaults( $session, $data )
 +
 +
</source>
 
Return default values for this object based on the starting data.
 
Return default values for this object based on the starting data.
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_user_with_email -->==user_with_email==
 
  
  $user = EPrints::DataObj::User::user_with_email( $session, $email )
+
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_user_with_email -->
 +
===user_with_email===
 +
 
 +
<source lang="perl">$user = EPrints::DataObj::User::user_with_email( $session, $email )
 +
 
 +
</source>
 +
Return the EPrints::user with the specified $email, or undef if they are not found.
 +
 
 +
<!-- Edit below this comment -->
 +
 
  
Return the EPrints::user with the specified $email, or undef if theyare not found.
+
<!-- Pod2Wiki= -->
<!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki=head_user_with_username -->
<!-- Pod2Wiki=item_user_with_username -->==user_with_username==
+
===user_with_username===
  
  $user = EPrints::DataObj::User::user_with_username( $session, $username )
+
<source lang="perl">$user = EPrints::DataObj::User::user_with_username( $session, $username )
  
Return the EPrints::user with the specified $username, or undef if they are not found.
+
</source>
<!-- End of Pod2Wiki -->
+
Return the EPrints::user with the specified $username, or undef if they are not found.
<!-- Pod2Wiki=item_validate -->==validate==
 
  
  $problems = $thing-&gt;validate
+
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_validate -->
 +
===validate===
 +
 
 +
<source lang="perl">$problems = $thing->validate
 +
 
 +
</source>
 +
Validate the user - find out if all the required fields are filled out, and that what's been filled in is OK. Returns a reference to an array of problem descriptions.
  
Validate the user - find out if all the required fields are filledout, and that what's been filled in is OK. Returns a reference to anarray of problem descriptions.
 
 
If there are no probelms then the array is empty.
 
If there are no probelms then the array is empty.
 +
 
The problems are XHTML DOM objects describing the problem.
 
The problems are XHTML DOM objects describing the problem.
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_commit -->==commit==
 
  
  $user-&gt;commit( [$force] )
+
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_commit -->
 +
===commit===
 +
 
 +
<source lang="perl">$user->commit( [$force] )
  
 +
</source>
 
Write this object to the database.
 
Write this object to the database.
If $force isn't true then it only actually modifies the databaseif one or more fields have been changed.
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_remove -->==remove==
 
  
  $success = $user-&gt;remove
+
If $force isn't true then it only actually modifies the database if one or more fields have been changed.
  
Remove this user from the database. Also, remove their saved searches,but do not remove their eprints.
+
<!-- Edit below this comment -->
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_eprints -->==get_eprints==
 
  
  $list = $user-&gt;get_eprints( $dataset )
 
  
Return EPrints in the given EPrints::DataSet which have this useras their creator.
+
<!-- Pod2Wiki= -->
Since 2.4 this returns an EPrints::List object, not an array of eprints.
+
<!-- Pod2Wiki=head_remove -->
<!-- End of Pod2Wiki -->
+
===remove===
<!-- Pod2Wiki=item_get_editable_eprints -->==get_editable_eprints==
 
  
  $list = $user-&gt;get_editable_eprints
+
<source lang="perl">$success = $user->remove
  
Return eprints currently in the editorial review buffer. If this userhas editperms set then only return those records which match.
+
</source>
Since 2.4 this returns an EPrints::List object, not an array of eprints.
+
Remove this user from the database. Also, remove their saved searches, but do not remove their eprints.
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_owned_eprints -->==get_owned_eprints==
 
  
  $list = $user-&gt;get_owned_eprints( $dataset );
+
<!-- Edit below this comment -->
  
Return a list of the eprints which this user owns. This is by defaultthe same as $user-&gt;get_eprints( $dataset) but may be over-ridden byget_users_owned_eprints.
 
Since 2.4 this returns an EPrints::List object, not an array of eprints.
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_has_owner -->==has_owner==
 
  
  $boolean = $user-&gt;has_owner( $possible_owner )
+
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_is_staff -->
 +
===is_staff===
  
 +
<source lang="perl">$bool = $user->is_staff()
 +
 +
</source>
 +
Returns true if the user's type is '''editor''' or '''admin'''.
 +
 +
<!-- Edit below this comment -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_langauge -->
 +
===langauge===
 +
 +
<source lang="perl">$lang = $user->langauge()
 +
 +
</source>
 +
Get the preferred language of the user.
 +
 +
<!-- Edit below this comment -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_owned_eprints_list -->
 +
===owned_eprints_list===
 +
 +
<source lang="perl">$list = $user->owned_eprints_list( %opts )
 +
 +
</source>
 +
Returns a [[API:EPrints/List|EPrints::List]] of all the [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]]s owned by this user.
 +
 +
%opts is passed to a [[API:EPrints/Search|EPrints::Search]] which is used to filter the results.
 +
 +
<!-- Edit below this comment -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_editable_eprints_list -->
 +
===editable_eprints_list===
 +
 +
<source lang="perl">$list = $user->editable_eprints_list( %opts )
 +
 +
</source>
 +
Returns a [[API:EPrints/List|EPrints::List]] of [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]]s that match this user's editorial search expressions. If the user has no editorial scope a list of all eprints that match the given %opts is returned.
 +
 +
%opts is passed to a [[API:EPrints/Search|EPrints::Search]] which is used to filter the results.
 +
 +
<pre>  $list = $user-&gt;editable_eprints_list(
 +
      dataset =&gt; $repo-&gt;dataset( "buffer" ),
 +
    );</pre>
 +
 +
<!-- Edit below this comment -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_has_owner -->
 +
===has_owner===
 +
 +
<source lang="perl">$boolean = $user->has_owner( $possible_owner )
 +
 +
</source>
 
True if the users are the same record.
 
True if the users are the same record.
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_mail -->==mail==
 
  
  $ok = $user-&gt;mail( $subjectid, $message, [$replyto], [$email] )
+
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_mail -->
 +
===mail===
 +
 
 +
<source lang="perl">$ok = $user->mail( $subjectid, $message, [$replyto], [$email] )
  
 +
</source>
 
Send an email to this user.  
 
Send an email to this user.  
 +
 
$subjectid is the ID of a phrase to use as the subject of this email.
 
$subjectid is the ID of a phrase to use as the subject of this email.
 +
 
$message is an XML DOM object describing the message in simple XHTML.
 
$message is an XML DOM object describing the message in simple XHTML.
$replyto is the reply to address for this email, if different to therepository default.
+
 
$email is the email address to send this email to if different fromthis users configured email address.
+
$replyto is the reply to address for this email, if different to the repository default.
 +
 
 +
$email is the email address to send this email to if different from this users configured email address.
 +
 
 
Return true if the email was sent OK.
 
Return true if the email was sent OK.
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render -->==render==
 
  
  ( $page, $title ) = $user-&gt;render
+
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_render -->
 +
===render===
 +
 
 +
<source lang="perl">( $page, $title ) = $user->render
 +
 
 +
</source>
 +
Render this user into HTML using the "user_render" method in ArchiveRenderConfig.pm. Returns both the rendered information and the title as XHTML DOM.
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_render_full -->
 +
===render_full===
 +
 
 +
<source lang="perl">( $page, $title ) = $user->render_full
 +
 
 +
</source>
 +
The same as $user-&gt;render, but renders all fields, not just those  intended for public viewing. This is the admin view of the user.
  
Render this user into HTML using the "user_render" method inArchiveRenderConfig.pm. Returns both the rendered information andthe title as XHTML DOM.
+
<!-- Edit below this comment -->
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_full -->==render_full==
 
  
  ( $page, $title ) = $user-&gt;render_full
 
  
The same as $user-&gt;render, but renders all fields, not just those intended for public viewing. This is the admin view of the user.
+
<!-- Pod2Wiki= -->
<!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki=head_get_url -->
<!-- Pod2Wiki=item_get_url -->==get_url==
+
===get_url===
  
  $url = $user-&gt;get_url
+
<source lang="perl">$url = $user->get_url
  
 +
</source>
 
Return the URL which will display information about this user.
 
Return the URL which will display information about this user.
If $staff is true then return the URL for an administrator to viewand modify this record.
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_type -->==get_type==
 
  
  $type = $user-&gt;get_type
+
If $staff is true then return the URL for an administrator to view and modify this record.
 +
 
 +
<!-- Edit below this comment -->
 +
 
  
Return the type of this user. Equivalent of $user-&gt;get_value( "usertype" );
+
<!-- Pod2Wiki= -->
<!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki=head_get_type -->
<!-- Pod2Wiki=item_get_saved_searches -->==get_saved_searches==
+
===get_type===
  
  @saved_searches = $eprint-&gt;get_saved_searches
+
<source lang="perl">$type = $user->get_type
  
Return an array of all EPrint::DataObj::SavedSearch objects associated with thisuser.
+
</source>
<!-- End of Pod2Wiki -->
+
Return the type of this user. Equivalent of $user-&gt;get_value( "usertype" );
<!-- Pod2Wiki=item_send_out_editor_alert -->==send_out_editor_alert==
 
  
  $user-&gt;send_out_editor_alert
+
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_get_saved_searches -->
 +
===get_saved_searches===
 +
 
 +
<source lang="perl">@saved_searches = $eprint->get_saved_searches
 +
 
 +
</source>
 +
Return an array of all EPrint::DataObj::SavedSearch objects associated with this user.
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_preference -->
 +
===preference===
 +
 
 +
<source lang="perl">$value = $user->preference( $key )
 +
 
 +
</source>
 +
Retrieve the preference $key.
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_set_preference -->
 +
===set_preference===
 +
 
 +
<source lang="perl">$user->set_preference( $key, $value )
 +
 
 +
</source>
 +
Set a preference $key for the user to $value.
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_send_out_editor_alert -->
 +
===send_out_editor_alert===
 +
 
 +
<source lang="perl">$user->send_out_editor_alert
 +
 
 +
</source>
 +
Called on users who are editors, when it's time to send their update on what items are in the editorial review buffer.
  
Called on users who are editors, when it's time to send their updateon what items are in the editorial review buffer.
 
 
Sends the email if needed.
 
Sends the email if needed.
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_process_editor_alerts -->==process_editor_alerts==
 
  
  EPrints::DataObj::User::process_editor_alerts( $session, $frequency );
+
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_process_editor_alerts -->
 +
===process_editor_alerts===
  
 +
<source lang="perl">EPrints::DataObj::User::process_editor_alerts( $session, $frequency );
 +
 +
</source>
 
Static method.
 
Static method.
Called to send out all editor alerts of a given frequency (daily,weekly, monthly) for the current repository.
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_allow -->==allow==
 
  
  $result = $user-&gt;allow( $priv, [$item] )
+
Called to send out all editor alerts of a given frequency (daily, weekly, monthly) for the current repository.
  
 +
<!-- Edit below this comment -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_allow -->
 +
===allow===
 +
 +
<source lang="perl">$result = $user->allow( $priv )
 +
 +
</source>
 
Returns true if $user can perform this action/view this screen.
 
Returns true if $user can perform this action/view this screen.
A true result is 1..15 where the value indicates what about the userallowed the priv to be performed. This is used for filtering owner/editor actions in eprint control screens.
 
1 = anybody (not currently used)2 = only if logged in 4 = only if owner of item8 = only if editor of item
 
For non item related privs the result will normally be 2.
 
Nb. That create eprint is NOT a priv related to an eprint, as you don't own it at that stage.
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS=
 
{{API:Undocumented Methods}}<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_can_edit -->==can_edit==
 
  
<!-- End of Pod2Wiki -->
+
To test whether a privilege is possible on an object use [[API:EPrints/DataObj#permit|EPrints::DataObj/permit]].
<!-- Pod2Wiki=item_create -->==create==
+
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_has_privilege -->
 +
===has_privilege===
 +
 
 +
<source lang="perl">$boolean = $user->has_privilege( $priv )
 +
 
 +
</source>
 +
Returns true if $priv is in the user's privileges table.
 +
 
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_copyright -->
 +
==COPYRIGHT==
 +
Copyright 2000-2011 University of Southampton.
 +
 
 +
This file is part of EPrints http://www.eprints.org/.
  
<!-- End of Pod2Wiki -->
+
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
<!-- Pod2Wiki=item_create_from_data -->==create_from_data==
 
  
<!-- End of Pod2Wiki -->
+
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
<!-- Pod2Wiki=item_get_control_url -->==get_control_url==
 
  
<!-- End of Pod2Wiki -->
+
You should have received a copy of the GNU Lesser General Public License along with EPrints.  If not, see http://www.gnu.org/licenses/.
<!-- Pod2Wiki=item_get_privs -->==get_privs==
 
  
<!-- End of Pod2Wiki -->
+
<!-- Edit below this comment -->
<!-- Pod2Wiki=item_get_roles -->==get_roles==
 
  
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_has_role -->==has_role==
 
  
<!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=_postamble_ --><!-- End of Pod2Wiki -->
+
<!-- Pod2Wiki=_postamble_ -->
 +
<!-- Edit below this comment -->

Revision as of 09:57, 22 January 2013

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::DataObj::User - Class representing a single user.


DESCRIPTION

This class represents a single eprint user record and the metadata associated with it.

EPrints::DataObj::User is a subclass of EPrints::DataObj with the following metadata fields (plus those defined in ArchiveMetadataFieldsConfig:


SYSTEM METADATA

  • userid (int)
The unique ID number of this user record. Unique within the current repository.
  • rev_number (int)
The revision number of this record. Each time it is changed the revision number is increased. This is not currently used for anything but it may be used for logging later.
  • username (text)
The username of this user. Used for logging into the system. Unique within this repository.
  • password (secret)
The crypted password for this user as generated by EPrints::Utils/crypt. This may be ignored if for example LDAP authentication is being used.
  • usertype (namedset)
The type of this user. The options are configured in metadata-phrases.xml.
  • newemail (email)
Used to store a new but as yet unconfirmed email address.
  • newpassword (secret)
Used to store a new but as yet unconfirmed password.
  • pin (text)
A code required to confirm a new username or password. This code is emailed to the user to confirm they are who they say they are.
  • pinsettime (int)
When the pin code was set, so we can make it time out.
  • joined (time)
The date and time that the user account was created. Before EPrints 2.4 this was a date field so users created before the upgrade will appear to have been created at midnight.
  • email (email)
The email address of this user. Unique within the repository.
  • lang (namedset)
The ID of the prefered language of this user. Only really used in multilingual repositories.
  • editperms (search, multiple)
This field is used to filter what eprints a staff member can approve and modify. If it's unset then they can modify any (given the correct privs. but if it is set then an eprint must match at least one of the searches to be within their scope.
  • frequency (set)
Only relevant to staff accounts. Is the frequency they want to be mailed about eprints matching their scope that are in editorial review. never, daily, weekly or monthly.
  • mailempty (boolean)
Only relevant to staff accounts. If set to true then emails are sent even if there are no items matching the scope.
  • preference (compound)
User preferences which need to be persistent (simple key-value pairs).


METHODS

get_system_field_info

$field_info = EPrints::DataObj::User->get_system_field_info

Return an array describing the system metadata of the this dataset.


new

$user = EPrints::DataObj::User->new( $session, $userid )

Load the user with the ID of $userid from the database and return it as an EPrints::DataObj::User object.


new_from_data

$user = EPrints::DataObj::User->new_from_data( $session, $data )

Construct a new EPrints::DataObj::User object based on the $data hash reference of metadata.

Used to create an object from the data retrieved from the database.


get_dataset_id

$dataset = EPrints::DataObj::User->get_dataset_id

Returns the id of the EPrints::DataSet object to which this record belongs.


get_defaults

$defaults = EPrints::DataObj::User->get_defaults( $session, $data )

Return default values for this object based on the starting data.


user_with_email

$user = EPrints::DataObj::User::user_with_email( $session, $email )

Return the EPrints::user with the specified $email, or undef if they are not found.


user_with_username

$user = EPrints::DataObj::User::user_with_username( $session, $username )

Return the EPrints::user with the specified $username, or undef if they are not found.


validate

$problems = $thing->validate

Validate the user - find out if all the required fields are filled out, and that what's been filled in is OK. Returns a reference to an array of problem descriptions.

If there are no probelms then the array is empty.

The problems are XHTML DOM objects describing the problem.


commit

$user->commit( [$force] )

Write this object to the database.

If $force isn't true then it only actually modifies the database if one or more fields have been changed.


remove

$success = $user->remove

Remove this user from the database. Also, remove their saved searches, but do not remove their eprints.


is_staff

$bool = $user->is_staff()

Returns true if the user's type is editor or admin.


langauge

$lang = $user->langauge()

Get the preferred language of the user.


owned_eprints_list

$list = $user->owned_eprints_list( %opts )

Returns a EPrints::List of all the EPrints::DataObj::EPrints owned by this user.

%opts is passed to a EPrints::Search which is used to filter the results.


editable_eprints_list

$list = $user->editable_eprints_list( %opts )

Returns a EPrints::List of EPrints::DataObj::EPrints that match this user's editorial search expressions. If the user has no editorial scope a list of all eprints that match the given %opts is returned.

%opts is passed to a EPrints::Search which is used to filter the results.

  $list = $user->editable_eprints_list(
      dataset => $repo->dataset( "buffer" ),
     );


has_owner

$boolean = $user->has_owner( $possible_owner )

True if the users are the same record.


mail

$ok = $user->mail( $subjectid, $message, [$replyto], [$email] )

Send an email to this user.

$subjectid is the ID of a phrase to use as the subject of this email.

$message is an XML DOM object describing the message in simple XHTML.

$replyto is the reply to address for this email, if different to the repository default.

$email is the email address to send this email to if different from this users configured email address.

Return true if the email was sent OK.


render

( $page, $title ) = $user->render

Render this user into HTML using the "user_render" method in ArchiveRenderConfig.pm. Returns both the rendered information and the title as XHTML DOM.


render_full

( $page, $title ) = $user->render_full

The same as $user->render, but renders all fields, not just those intended for public viewing. This is the admin view of the user.


get_url

$url = $user->get_url

Return the URL which will display information about this user.

If $staff is true then return the URL for an administrator to view and modify this record.


get_type

$type = $user->get_type

Return the type of this user. Equivalent of $user->get_value( "usertype" );


get_saved_searches

@saved_searches = $eprint->get_saved_searches

Return an array of all EPrint::DataObj::SavedSearch objects associated with this user.


preference

$value = $user->preference( $key )

Retrieve the preference $key.


set_preference

$user->set_preference( $key, $value )

Set a preference $key for the user to $value.


send_out_editor_alert

$user->send_out_editor_alert

Called on users who are editors, when it's time to send their update on what items are in the editorial review buffer.

Sends the email if needed.


process_editor_alerts

EPrints::DataObj::User::process_editor_alerts( $session, $frequency );

Static method.

Called to send out all editor alerts of a given frequency (daily, weekly, monthly) for the current repository.


allow

$result = $user->allow( $priv )

Returns true if $user can perform this action/view this screen.

To test whether a privilege is possible on an object use EPrints::DataObj/permit.


has_privilege

$boolean = $user->has_privilege( $priv )

Returns true if $priv is in the user's privileges table.


COPYRIGHT

Copyright 2000-2011 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.