本文整理汇总了PHP中Institution::admins方法的典型用法代码示例。如果您正苦于以下问题:PHP Institution::admins方法的具体用法?PHP Institution::admins怎么用?PHP Institution::admins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Institution
的用法示例。
在下文中一共展示了Institution::admins方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
<?php
/**
*
* @package mahara
* @subpackage core
* @author Stacey Walker
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('MENUITEM', '');
define('SECTION_PLUGINTYPE', 'core');
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'institution.php';
if (!is_logged_in()) {
throw new AccessDeniedException();
}
$inst = param_alpha('institution');
$institution = new Institution($inst);
$admins = $institution->admins();
$staff = $institution->staff();
build_stafflist_html($admins, 'institution', 'admin', $inst);
build_stafflist_html($staff, 'institution', 'staff', $inst);
define('TITLE', $institution->displayname);
$smarty = smarty();
$smarty->assign('admins', $admins);
$smarty->assign('staff', $staff);
$smarty->assign('PAGEHEADING', get_string('institutioncontacts', 'mahara', TITLE));
$smarty->display('institution/staffadmin.tpl');
示例2: auth_register_submit
function auth_register_submit(Pieform $form, $values)
{
global $SESSION;
safe_require('auth', 'internal');
$values['key'] = get_random_key();
$values['lang'] = $SESSION->get('lang');
// If the institution requires approval, mark the record as pending
// @todo the expiry date should be configurable
if ($confirm = get_config('requireregistrationconfirm') || get_field('institution', 'registerconfirm', 'name', $values['institution'])) {
if (isset($values['authtype']) && $values['authtype'] != 'internal') {
$authinstance = get_record('auth_instance', 'institution', $values['institution'], 'authname', $values['authtype'] ? $values['authtype'] : 'internal');
$auth = AuthFactory::create($authinstance->id);
$confirm = !$auth->weautocreateusers;
}
if ($confirm) {
$values['pending'] = 1;
$values['expiry'] = db_format_timestamp(time() + 86400 * 14);
// now + 2 weeks
} else {
$values['pending'] = 0;
$values['expiry'] = db_format_timestamp(time() + 86400);
}
} else {
$values['pending'] = 0;
$values['expiry'] = db_format_timestamp(time() + 86400);
}
if (function_exists('local_register_submit')) {
local_register_submit($values);
}
try {
if (!record_exists('usr_registration', 'email', $values['email'])) {
insert_record('usr_registration', $values);
} else {
update_record('usr_registration', $values, array('email' => $values['email']));
}
$user = (object) $values;
$user->admin = 0;
$user->staff = 0;
// If the institution requires approval, notify institutional admins.
if ($confirm) {
$fullname = sprintf("%s %s", trim($user->firstname), trim($user->lastname));
$institution = new Institution($values['institution']);
$pendingregistrationslink = sprintf("%sadmin/users/pendingregistrations.php?institution=%s", get_config('wwwroot'), $values['institution']);
// list of admins for this institution
if (count($institution->admins()) > 0) {
$admins = $institution->admins();
} else {
// use site admins if the institution doesn't have any
$admins = get_column('usr', 'id', 'admin', 1, 'deleted', 0);
}
require_once get_config('libroot') . 'pieforms/pieform/elements/expiry.php';
$expirytime = pieform_element_expiry_get_expiry_from_seconds(get_config('defaultregistrationexpirylifetime'));
if ($expirytime == null) {
$expirystring = get_config('defaultregistrationexpirylifetime') . ' ' . get_string('seconds', 'performance');
} else {
if ($expirytime['units'] == 'noenddate') {
$expirystring = get_string('element.expiry.noenddate', 'pieforms');
} else {
$expirystring = $expirytime['number'] . ' ' . get_string('element.expiry.' . $expirytime['units'], 'pieforms');
}
}
// email each admin
// @TODO Respect the notification preferences of the admins.
foreach ($admins as $admin) {
$adminuser = new User();
$adminuser->find_by_id($admin);
email_user($adminuser, null, get_string('pendingregistrationadminemailsubject', 'auth.internal', $institution->displayname, get_config('sitename')), get_string('pendingregistrationadminemailtext', 'auth.internal', $adminuser->firstname, $institution->displayname, $pendingregistrationslink, $expirystring, $fullname, $values['email'], $values['reason'], get_config('sitename')), get_string('pendingregistrationadminemailhtml', 'auth.internal', $adminuser->firstname, $institution->displayname, $pendingregistrationslink, $pendingregistrationslink, $expirystring, $fullname, $values['email'], $values['reason'], get_config('sitename')));
}
email_user($user, null, get_string('approvalemailsubject', 'auth.internal', get_config('sitename')), get_string('approvalemailmessagetext', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('sitename')), get_string('approvalemailmessagehtml', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('sitename')));
$_SESSION['registeredokawaiting'] = true;
} else {
if (isset($values['authtype']) && $values['authtype'] == 'browserid') {
redirect('/register.php?key=' . $values['key']);
} else {
email_user($user, null, get_string('registeredemailsubject', 'auth.internal', get_config('sitename')), get_string('registeredemailmessagetext', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('sitename')), get_string('registeredemailmessagehtml', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('wwwroot'), $values['key'], get_config('sitename')));
}
// Add a marker in the session to say that the user has registered
$_SESSION['registered'] = true;
}
} catch (EmailException $e) {
log_warn($e);
die_info(get_string('registrationunsuccessful', 'auth.internal'));
} catch (SQLException $e) {
log_warn($e);
die_info(get_string('registrationunsuccessful', 'auth.internal'));
}
redirect($values['goto']);
}
示例3: export_process_queue
//.........这里部分代码省略.........
// so we need to put it somewhere safe
if (!empty($submitted->submittedtime)) {
// Now set up the export submission directories
$submissiondir = get_config('dataroot') . 'submission/' . $row->usr . '/';
if (!check_dir_exists($submissiondir)) {
$errors[] = get_string('submissiondirnotwritable', 'export', $submissiondir);
} else {
copy($filepath . $zipfile, $submissiondir . $zipfile);
$filepath = $submissiondir;
}
}
$filetitle = '';
if (!empty($row->type)) {
switch ($row->type) {
case 'all':
$filetitle = get_string('allmydata', 'export');
break;
default:
$filetitle = get_string('exporting' . $row->type, 'export');
}
} else {
$filetitle = !empty($submitted->name) ? $submitted->name : $submitted->title;
}
$externalhost = !empty($submitted->submittedhost) ? $submitted->submittedhost : null;
db_begin();
// Need to record this in the export_archive table so one can fetch the file via a download link
$archiveid = insert_record('export_archive', (object) array('usr' => $row->usr, 'filename' => $zipfile, 'filetitle' => $filetitle, 'filepath' => $filepath, 'submission' => !empty($submitted->submittedtime) ? 1 : 0, 'ctime' => db_format_timestamp(time())), 'id', true);
if (!$archiveid) {
$errors[] = get_string('exportarchivesavefailed', 'export');
}
// If the export row is for a submitted view/collection
if (!empty($submitted->submittedtime)) {
$inserted = insert_record('archived_submissions', (object) array('archiveid' => $archiveid, 'group' => $submitted->submittedgroup, 'externalhost' => $externalhost, 'externalid' => $row->externalid));
if (!$inserted) {
$errors[] = get_string('archivedsubmissionfailed', 'export');
}
require_once get_config('docroot') . 'lib/view.php';
if ($submitted->submittedstatus == View::PENDING_RELEASE) {
// we are running this export as part of the releasing submission process
if ($row->what == 'collections') {
require_once get_config('docroot') . 'lib/collection.php';
$id = substr($lastid, strlen('collection_'));
$collection = new Collection($id);
try {
$collection->release($row->submitter);
} catch (SystemException $e) {
$errors[] = get_string('submissionreleasefailed', 'export');
log_warn($e->getMessage());
}
} else {
if ($row->what == 'views') {
$id = substr($lastid, strlen('view_'));
$view = new View($id);
try {
$view->release($row->submitter);
} catch (SystemException $e) {
$errors[] = get_string('submissionreleasefailed', 'export');
log_warn($e->getMessage());
}
} else {
$errors[] = get_string('submissionreleasefailed', 'export');
}
}
}
} else {
// Need to send emails with the download link in them - so we add the data to the activity_queue table
$arg = display_name($row->usr);
$data = (object) array('subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => 'exportdownloademailsubject', 'section' => 'admin', 'args' => array($filetitle)), 'message' => (object) array('key' => 'exportdownloademailmessage', 'section' => 'admin', 'args' => array(hsc($arg), $filetitle)), 'urltext' => (object) array('key' => 'exportdownloadurl', 'section' => 'admin')), 'users' => array($row->usr), 'url' => get_config('webroot') . 'downloadarchive.php?id=' . $archiveid);
activity_occurred('maharamessage', $data);
}
// finally delete the queue item
if (!delete_records('export_queue_items', 'exportqueueid', $row->id)) {
$errors[] = get_string('deleteexportqueueitems', 'export', $row->id);
log_warn('Unable to delete export queue items for ID: ' . $row->id);
}
if (!delete_records('export_queue', 'id', $row->id)) {
$errors[] = get_string('deleteexportqueuerow', 'export', $row->id);
log_warn('Unable to delete export queue row ID: ' . $row->id);
}
// if there are any errors then we need to alert the site and institution admins
if (!empty($errors)) {
$admins = get_column('usr', 'id', 'admin', 1, 'deleted', 0);
$institutions = $user->get('institutions');
if (!empty($institutions)) {
foreach ($institutions as $key => $value) {
require_once get_config('docroot') . 'lib/institution.php';
$institution = new Institution($key);
$admins = array_merge($admins, $institution->admins());
}
}
$arg = "\n\n -" . implode("\n - ", $errors);
$data = (object) array('subject' => false, 'message' => false, 'strings' => (object) array('subject' => (object) array('key' => 'exportqueueerrorsadminsubject', 'section' => 'export'), 'message' => (object) array('key' => 'exportqueueerrorsadminmessage', 'section' => 'export', 'args' => array(hsc($row->id), hsc($arg))), 'urltext' => (object) array('key' => 'exportdownloadurl', 'section' => 'admin')), 'users' => $admins, 'url' => get_config('webroot') . 'admin/users/exportqueue.php');
activity_occurred('maharamessage', $data);
db_rollback();
} else {
db_commit();
}
}
return true;
}