本文整理汇总了PHP中company::get方法的典型用法代码示例。如果您正苦于以下问题:PHP company::get方法的具体用法?PHP company::get怎么用?PHP company::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类company
的用法示例。
在下文中一共展示了company::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: total_companies
/**
* Theme functions for companies
*/
function total_companies()
{
if (!($companies = Registry::get('companies'))) {
$companies = company::get();
$companies = new Items($companies);
Registry::set('companies', $companies);
}
return $companies->length();
}
示例2: create
/**
* Creates a user using company user defaults and attaches it to a company
* User will be emailed a password when the cron job has run
* @param object $data
* @return userid
*/
public static function create($data)
{
global $DB, $CFG, $USER;
if ($data->companyid) {
$company = new company($data->companyid);
$c = $company->get('shortname');
$data->company = $c->shortname;
} else {
$company = company::by_shortname($data->company);
}
$defaults = $company->get_user_defaults();
$user = (object) array_merge((array) $defaults, (array) $data);
//$user->username = self::generate_username( $user->email ); //GWL : Remove Generate Usernaame From Email for Phone No.
//$user->username = clean_param($user->username, PARAM_USERNAME); //GWL : Remove Generate Usernaame From Email for Phone No.
/* GWL : Get Usernamme as phone no. */
$user->username = $user->phone;
/* GWL : Get Usernamme as phone no. */
// Deal with the company theme.
$user->theme = $company->get_theme();
if ($user->sendnewpasswordemails && !$user->preference_auth_forcepasswordchange) {
throw new Exception(get_string('cannotemailnontemporarypasswords', 'local_iomad'));
}
/*
There are 8 possible combinations of password, sendbyemail and forcepasswordchange
fields:
pwd email yes force change -> temporary password
pwd email no force change -> temporary password
pwd email no dont force change -> not a temporary password
no pwd email yes force change -> create password -> store temp
no pwd email no force change -> create password -> store temp
no pwd email no dont force change -> create password -> store temp
These two combinations shouldn't happen (caught by form validation and exception above):
pwd email yes dont force change->needs to be stored as temp password -> not secure
no pwd email yes dont force change->create password->store temp->not secure
The next set of variables ($sendemail, $passwordentered, $createpassword,
$forcepasswordchange, $storetemppassword) are used to distinguish between
the first 6 combinations and to take appropriate action.
*/
$sendemail = $user->sendnewpasswordemails;
$passwordentered = !empty($user->newpassword);
$createpassword = !$passwordentered;
$forcepasswordchange = $user->preference_auth_forcepasswordchange;
// Store temp password unless password was entered and it's not going to be send by
// email nor is it going to be forced to change.
$storetemppassword = !($passwordentered && !$sendemail && !$forcepasswordchange);
if ($passwordentered) {
$user->password = $user->newpassword;
// Don't hash it, user_create_user will do that.
}
$user->confirmed = 1;
$user->mnethostid = 1;
$user->maildisplay = 0;
// Hide email addresses by default.
// Create user record and return id.
$id = user_create_user($user);
$user->id = $id;
// Passwords will be created and sent out on cron.
if ($createpassword) {
set_user_preference('create_password', 1, $user->id);
$user->newpassword = generate_password();
if (!empty($CFG->iomad_email_senderisreal)) {
EmailTemplate::send('user_create', array('user' => $user, 'sender' => $USER));
} else {
EmailTemplate::send('user_create', array('user' => $user, 'headers' => serialize(array("To:" . $user->email . ", " . $USER->email))));
}
$sendemail = false;
}
if ($forcepasswordchange) {
set_user_preference('auth_forcepasswordchange', 1, $user->id);
}
if ($createpassword) {
$DB->set_field('user', 'password', hash_internal_user_password($user->newpassword), array('id' => $user->id));
}
if ($storetemppassword) {
// Store password as temporary password, sendemail if necessary.
self::store_temporary_password($user, $sendemail, $user->newpassword);
}
// Attach user to company.
// Do we have a department?
if (empty($data->departmentid)) {
$departmentinfo = $DB->get_record('department', array('company' => $company->id, 'parent' => 0));
$data->departmentid = $departmentinfo->id;
}
// Deal with unset variable.
if (empty($data->managertype)) {
$data->managertype = 0;
}
// Create the user association.
$DB->insert_record('company_users', array('userid' => $user->id, 'companyid' => $company->id, 'managertype' => $data->managertype, 'departmentid' => $data->departmentid));
if (isset($data->selectedcourses)) {
//.........这里部分代码省略.........
示例3: array
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
echo $OUTPUT->header();
$companyids = $DB->get_records_menu('company', array(), 'id, name');
//$companyids['none'] = get_string('nocompany', 'block_iomad_company_admin');
$companyids[''] = get_string('selectacompany', 'block_iomad_company_admin');
ksort($companyids);
$companyselect = new single_select(new moodle_url('/local/company_navigation/manage_company.php'), 'companyid', $companyids, $companyid);
$companyselect->label = get_string('company', 'block_iomad_company_admin');
$companyselect->formid = 'choosecompany';
echo html_writer::tag('div', $OUTPUT->render($companyselect), array('id' => 'iomad_company_selector')) . '</br>';
// get company detail
if ($companyid) {
$company = new company($companyid);
$table = new html_table();
$table->head = array(get_string('companyadminstration', 'local_company_navigation', $company->get_name()));
if ($company->get()) {
// check company record exist and set it to session variable as current company
$SESSION->currenteditingcompany = $company->id;
}
if (isset($SESSION->currenteditingcompany)) {
$companymanagelinks = get_company_manage_links($SESSION->currenteditingcompany);
foreach ($companymanagelinks as $linktext => $linkurl) {
$link = $linktext;
if ($linkurl) {
$link = '<a href=' . $linkurl . '>' . $linktext . '</a>';
}
$table->data[] = array($link);
}
if ($companymanagelinks) {
echo html_writer::table($table);
}