本文整理汇总了PHP中Institution::addUserAsMember方法的典型用法代码示例。如果您正苦于以下问题:PHP Institution::addUserAsMember方法的具体用法?PHP Institution::addUserAsMember怎么用?PHP Institution::addUserAsMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Institution
的用法示例。
在下文中一共展示了Institution::addUserAsMember方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: join_institution
public function join_institution($institution)
{
if ($institution != 'mahara' && !$this->in_institution($institution)) {
require_once 'institution.php';
$institution = new Institution($institution);
$institution->addUserAsMember($this);
$this->reset_institutions();
}
}
示例2: create_user
/**
* Create user
*
* @param object $user stdclass or User object for the usr table
* @param array $profile profile field/values to set
* @param string|object $institution Institution the user should joined to (name or Institution object)
* @param bool $remoteauth authinstance record for a remote authinstance
* @param string $remotename username on the remote site
* @param array $accountprefs user account preferences to set
* @return integer id of the new user
*/
function create_user($user, $profile = array(), $institution = null, $remoteauth = null, $remotename = null, $accountprefs = array(), $quickhash = false)
{
db_begin();
if ($user instanceof User) {
$user->create();
$user->quota_init();
$user->commit();
$user = $user->to_stdclass();
} else {
$user->ctime = db_format_timestamp(time());
// Ensure this user has a profile urlid
if (get_config('cleanurls') && (!isset($user->urlid) || is_null($user->urlid))) {
$user->urlid = generate_urlid($user->username, get_config('cleanurluserdefault'), 3, 30);
$user->urlid = get_new_profile_urlid($user->urlid);
}
if (empty($user->quota)) {
$user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
}
if (get_config('defaultaccountlifetime')) {
// we need to set the user expiry to the site default one
$user->expiry = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')) + (int) get_config('defaultaccountlifetime'));
}
$user->id = insert_record('usr', $user, 'id', true);
}
if (isset($user->email) && $user->email != '') {
set_profile_field($user->id, 'email', $user->email, TRUE);
}
if (isset($user->firstname) && $user->firstname != '') {
set_profile_field($user->id, 'firstname', $user->firstname, TRUE);
}
if (isset($user->lastname) && $user->lastname != '') {
set_profile_field($user->id, 'lastname', $user->lastname, TRUE);
}
foreach ($profile as $k => $v) {
if (in_array($k, array('firstname', 'lastname', 'email'))) {
continue;
}
set_profile_field($user->id, $k, $v, TRUE);
}
if (!empty($institution)) {
if (is_string($institution)) {
$institution = new Institution($institution);
}
if ($institution->name != 'mahara') {
$institution->addUserAsMember($user);
// uses $user->newuser
if (empty($accountprefs['licensedefault'])) {
$accountprefs['licensedefault'] = LICENSE_INSTITUTION_DEFAULT;
}
}
}
$authobj = get_record('auth_instance', 'id', $user->authinstance);
$authinstance = AuthFactory::create($authobj->id);
// For legacy compatibility purposes, we'll also put the remote auth on there if it has been
// specifically requested.
if ($authinstance->needs_remote_username() || !empty($remoteauth)) {
if (isset($remotename) && strlen($remotename) > 0) {
$un = $remotename;
} else {
$un = $user->username;
}
// remote username must not already exist
if (record_exists('auth_remote_user', 'remoteusername', $un, 'authinstance', $user->authinstance)) {
throw new InvalidArgumentException("user_create: remoteusername already exists: ({$un}, {$user->authinstance})");
}
insert_record('auth_remote_user', (object) array('authinstance' => $user->authinstance, 'remoteusername' => $un, 'localusr' => $user->id));
}
// Set account preferences
if (!empty($accountprefs)) {
$expectedprefs = expected_account_preferences();
foreach ($expectedprefs as $eprefkey => $epref) {
if (isset($accountprefs[$eprefkey]) && $accountprefs[$eprefkey] != $epref) {
set_account_preference($user->id, $eprefkey, $accountprefs[$eprefkey]);
}
}
}
// Copy site views and collections to the new user's profile
$userobj = new User();
$userobj->find_by_id($user->id);
$userobj->copy_site_views_collections_to_new_user();
reset_password($user, false, $quickhash);
handle_event('createuser', $user);
db_commit();
return $user->id;
}
示例3: create_user
/**
* Create user
*
* @param object $user stdclass or User object for the usr table
* @param array $profile profile field/values to set
* @param string $institution Institution the user should joined to
* @param stdclass $remoteauth authinstance record for a remote authinstance
* @param string $remotename username on the remote site
* @return integer id of the new user
*/
function create_user($user, $profile = array(), $institution = null, $remoteauth = null, $remotename = null)
{
db_begin();
if ($user instanceof User) {
$user->create();
$user->quota_init();
$user->commit();
$user = $user->to_stdclass();
} else {
$user->ctime = db_format_timestamp(time());
if (empty($user->quota)) {
$user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
}
$user->id = insert_record('usr', $user, 'id', true);
}
// Bypass access check for 'copynewuser' institution/site views, because this user may not be logged in yet
$user->newuser = true;
if (isset($user->email) && $user->email != '') {
set_profile_field($user->id, 'email', $user->email);
}
if (isset($user->firstname) && $user->firstname != '') {
set_profile_field($user->id, 'firstname', $user->firstname);
}
if (isset($user->lastname) && $user->lastname != '') {
set_profile_field($user->id, 'lastname', $user->lastname);
}
foreach ($profile as $k => $v) {
if (in_array($k, array('firstname', 'lastname', 'email'))) {
continue;
}
set_profile_field($user->id, $k, $v);
}
if (!empty($institution) && $institution != 'mahara') {
if (is_string($institution)) {
$institution = new Institution($institution);
}
if ($institution->name != 'mahara') {
$institution->addUserAsMember($user);
// uses $user->newuser
}
}
if (!empty($remoteauth) && $remoteauth->authname != 'internal') {
if (isset($remotename) && strlen($remotename) > 0) {
$un = $remotename;
} else {
$un = $user->username;
}
delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'remoteusername', $un);
insert_record('auth_remote_user', (object) array('authinstance' => $user->authinstance, 'remoteusername' => $un, 'localusr' => $user->id));
}
// Copy site views to the new user's profile
$checkviewaccess = !$user->newuser;
$userobj = new User();
$userobj->find_by_id($user->id);
$userobj->copy_views(get_column('view', 'id', 'institution', 'mahara', 'copynewuser', 1), $checkviewaccess);
handle_event('createuser', $user);
db_commit();
return $user->id;
}
示例4: dirname
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage admin
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('INSTITUTIONALADMIN', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require 'institution.php';
$id = param_integer('id');
$institution = new Institution(param_alpha('institution'));
if (!$USER->get('admin')) {
if (!$USER->is_institutional_admin($institution->name)) {
$SESSION->add_error_msg(get_string('notadminforinstitution', 'admin'));
redirect(get_config('wwwroot') . 'admin/users/search.php');
} else {
if (!get_field('usr_institution_request', 'confirmedusr', 'usr', $id, 'institution', $institution->name)) {
$institution->inviteUser($id);
$SESSION->add_ok_msg(get_string('invitationsent', 'admin'));
redirect(get_config('wwwroot') . 'admin/users/search.php');
}
}
}
$institution->addUserAsMember($id);
$SESSION->add_ok_msg(get_string('useradded', 'admin'));
redirect(get_config('wwwroot') . 'admin/users/edit.php?id=' . $id);