本文整理汇总了PHP中Teacher::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Teacher::exists方法的具体用法?PHP Teacher::exists怎么用?PHP Teacher::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Teacher
的用法示例。
在下文中一共展示了Teacher::exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restore_filter
/**
* This method will return data by filter name.
* If the second and third parameters are set, it will check teacher data for his prefered course and
* inject this value into filter by specified conditions, only if these filter data are empty.
* @param string $filter_name name of filter.
* @param integer|Teacher $teacher teacher id or teacher object.
* @param string $course_field field in filter which contain course id in filter.
* @return array<midex> filter data.
*/
public function restore_filter($filter_name, $teacher = NULL, $course_field = NULL)
{
$filters = $this->CI->session->userdata(self::FILTERS_ARRAY);
$filters = empty($filters) || is_null($filters) || !is_array($filters) ? array() : $filters;
$filter = array_key_exists($filter_name, $filters) ? $filters[$filter_name] : array();
if (!is_null($teacher) && !is_null($course_field) && is_string($course_field) && empty($filter)) {
if (!is_object($teacher) || !$teacher instanceof Teacher) {
$teacher_id = $teacher;
$teacher = new Teacher();
$teacher->get_by_id(intval($teacher_id));
}
if ($teacher->exists()) {
$filter[$course_field] = $teacher->prefered_course_id;
}
}
return $filter;
}
示例2: _send_multiple_emails
/**
* Sends message to all students or teachers. Do not use get_iterated() to execute select query!
* @param Student|Teacher $recipients list of students or teachers.
* @param string $subject email subject (accepts lang: prefix).
* @param string $template template body or file:path/to/template.tpl.
* @param string $template_variables array of template variables.
* @param string $from email addres of sender or NULL to use system address.
* @param string $from_name name of sender.
* @param boolean $sender_copy enable sending of copy to sender email address.
* @param string $sender_email sender email address.
* @return boolean TRUE, if all emails are sent, or FALSE if all or some emails failed to be send.
*/
protected function _send_multiple_emails($recipients, $subject, $template, $template_variables = array(), $from = NULL, $from_name = '', $sender_copy = FALSE, $sender_email = '')
{
if ($recipients instanceof Teacher || $recipients instanceof Student) {
$email_by_languages = array();
if ($recipients->exists()) {
foreach ($recipients->all as $recipient) {
$email_by_languages[$recipient->language][] = $recipient;
}
}
if (count($email_by_languages) == 0) {
return FALSE;
}
$this->load->library('email');
if (is_null($from)) {
$this->email->from_system();
$this->email->reply_to_system();
} else {
$this->email->from($from, $from_name);
$this->email->reply_to($from, $from_name);
}
$result = TRUE;
$lang_clone = clone $this->lang;
set_time_limit(0);
foreach ($email_by_languages as $language => $subrecipients) {
if (count($subrecipients) == 0) {
continue;
}
$this->_init_specific_language($language);
$this->email->build_message_body($template, $template_variables);
$email_subject = 'LIST' . ($subject ? ' - ' . $this->lang->text($subject) : '');
if ($this->config->item('email_multirecipient_batch_mode')) {
$to_list = array();
foreach ($subrecipients as $recipient) {
$to_list[] = $recipient->email;
}
if ($sender_copy === TRUE) {
$to_list[] = $sender_email;
}
$this->email->to($to_list);
$this->email->subject($email_subject);
$partial_result = $this->email->send();
$result = $result && $partial_result;
} else {
foreach ($subrecipients as $recipient) {
$this->email->to($recipient->email);
$this->email->subject($email_subject);
$partial_result = $this->email->send();
$result = $result && $partial_result;
}
if ($sender_copy === TRUE) {
$this->email->to($sender_email);
$this->email->subject($email_subject);
$partial_result = $this->email->send();
$result = $result && $partial_result;
}
}
}
$this->lang = $lang_clone;
set_time_limit((int) ini_get('max_execution_time'));
return $result;
} else {
return FALSE;
}
}
示例3: refresh_teacher_userdata
/**
* Reloads teacher data from database to session.
*/
public function refresh_teacher_userdata()
{
if ($this->is_teacher_session_valid()) {
$userdata = $this->CI->session->userdata(SESSION_AUTH_LOGIN_TEACHER);
$teacher = new Teacher();
$teacher->get_by_id(@$userdata['id']);
if ($teacher->exists()) {
$userdata = $teacher->to_array();
unset($userdata['password']);
unset($userdata['created']);
unset($userdata['updated']);
$this->CI->session->set_userdata(SESSION_AUTH_LOGIN_TEACHER, $userdata);
}
}
}
示例4: comments_subscribe
public function comments_subscribe($task_set_id)
{
$output = new stdClass();
$this->_transaction_isolation();
$this->db->trans_begin();
$task_set = new Task_set();
$task_set->get_by_id(intval($task_set_id));
$teacher = new Teacher();
$teacher->get_by_id($this->usermanager->get_teacher_id());
if ($teacher->exists() && $task_set->exists() && $teacher->save(array('comment_subscription' => $task_set))) {
$this->db->trans_commit();
$output->message = $this->lang->line('admin_task_sets_comments_my_settings_subscribe_success');
$output->result = TRUE;
} else {
$this->db->trans_rollback();
$output->message = $this->lang->line('admin_task_sets_comments_my_settings_subscribe_error');
$output->result = FALSE;
}
$this->output->set_content_type('application/json');
$this->output->set_output(json_encode($output));
}
示例5: switch_prefered_course
public function switch_prefered_course($course_id, $current_url)
{
$this->usermanager->teacher_login_protected_redirect();
$this->_transaction_isolation();
$this->db->trans_begin();
$teacher = new Teacher();
$teacher->get_by_id($this->usermanager->get_teacher_id());
if ($teacher->exists()) {
$course = new Course();
$course->get_by_id($course_id);
if ($teacher->save(array('prefered_course' => $course))) {
$this->db->trans_commit();
$this->usermanager->refresh_teacher_userdata();
$this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_success', Messages::MESSAGE_TYPE_DEFAULT);
$this->load->library('filter');
$this->filter->set_all_filters_course($teacher->prefered_course_id);
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_failed', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:admin_teachers_prefered_course_quickchange_failed', Messages::MESSAGE_TYPE_ERROR);
}
redirect(decode_from_url($current_url));
}