本文整理汇总了PHP中HC_App::extensions方法的典型用法代码示例。如果您正苦于以下问题:PHP HC_App::extensions方法的具体用法?PHP HC_App::extensions怎么用?PHP HC_App::extensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HC_App
的用法示例。
在下文中一共展示了HC_App::extensions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index($tab = 'list')
{
$model = HC_App::model('user');
$layout = clone $this->layout;
/* build content */
$content = '';
$method = '_content_' . $tab;
if (method_exists($this, $method)) {
$content = $this->{$method}($model);
} else {
$extensions = HC_App::extensions();
if ($extensions->has(array('admin/users/index', $tab))) {
$calling_parent = 'admin/users/index' . '/' . $tab;
$content = $extensions->run(array('admin/users/index', $tab, $calling_parent));
}
}
$layout->set_partial('content', $content);
/* header */
$layout->set_partial('header', $this->render('admin/users/index/_header', array()));
/* menubar */
$layout->set_partial('menubar', $this->render('admin/users/index/_menubar', array('tab' => $tab, 'object' => $model)));
/* final layout */
$this->layout->set_partial('content', $this->render('admin/users/index/index', array('layout' => $layout)));
$this->layout();
}
示例2: update
function update($id)
{
$extensions = HC_App::extensions();
$args = func_get_args();
$id = array_shift($args);
$model = HC_App::model('shift');
$model->where('id', $id)->get();
$this->_check_model($model);
$acl = HC_App::acl();
if (!$acl->set_object($model)->can('edit')) {
return;
}
$original_model = clone $model;
/* supplied as parameters */
$values = hc_parse_args($args);
/* if post supplied */
$form = $this->form_edit;
$post = $this->input->post();
if ($post) {
$form->grab($post);
$form_values = $form->values();
$values = array_merge($values, $form_values);
}
if (!$values or !array_key_exists("action", $values)) {
$redirect_to = 'shifts/zoom/index/id/' . $id;
$this->redirect($redirect_to);
return;
}
/* approve */
if (!$model->release_request or $values['action']) {
$current_user = $this->auth->user();
$model->release_request = 0;
$model->user_id = 0;
$action_result = $model->save();
// $action_result = $model->delete($current_user, 'user');
$msg = HCM::__('Shift released');
} else {
$model->release_request = 0;
$action_result = $model->save();
$msg = HCM::__('Shift release rejected');
}
if ($action_result) {
/* extensions */
$extensions->run('shifts/update', $post, $model);
/* save and redirect here */
$this->session->set_flashdata('message', $msg);
$redirect_to = 'shifts/zoom/index/id/' . $id;
/* what to refresh on referring page */
$parent_refresh = $model->present_calendar_refresh();
$parent_refresh = array_keys($parent_refresh);
$this->redirect($redirect_to, $parent_refresh);
} else {
/* final layout */
$this->layout->set_partial('content', Modules::run('shifts/zoom/index', $model, 'release'));
$this->layout();
}
}
示例3: api_insert
function api_insert($post)
{
$extensions = HC_App::extensions();
$notifications_email_skip = isset($post['notifications_email_skip']) ? $post['notifications_email_skip'] : FALSE;
if ($notifications_email_skip) {
$messages = HC_App::model('messages');
$messages->remove_engine('email');
}
/* extensions */
$extensions->run('notifications_email/insert', $post);
$return = TRUE;
return $return;
}
示例4: __construct
function __construct()
{
parent::__construct();
if (defined('NTS_DEVELOPMENT')) {
if (!($this->input->is_ajax_request() or $this->is_module())) {
$this->output->enable_profiler(TRUE);
}
}
$this->load->database();
$ri = HC_Lib::ri();
if (!$this->is_setup()) {
$setup_redirect = 'setup';
if ($ri) {
$setup_redirect = $ri . '/setup';
}
$this->redirect($setup_redirect);
exit;
}
$this->load->library(array('session', 'hc_modules'));
/* add module models paths for autoloading */
$extensions = HC_App::extensions();
$acl = HC_App::acl();
$look_in_dirs = $this->config->look_in_dirs();
foreach ($look_in_dirs as $ldir) {
if (class_exists('Datamapper')) {
Datamapper::add_model_path($ldir);
}
$this->load->add_package_path($ldir);
$extensions->add_dir($ldir);
$acl->add_dir($ldir);
}
$extensions->init();
$acl->init();
/* reload config paths */
$app_conf = HC_App::app_conf();
$this->load->library('hc_modules');
/* events and notifiers */
$this->load->library(array('hc_events', 'hc_email'));
$this->hc_email->from = $app_conf->get('email_from');
$this->hc_email->fromName = $app_conf->get('email_from_name');
// conf
$this->load->library('hc_auth', NULL, 'auth');
$user = $this->auth->user();
$acl->set_user($user);
$CI =& ci_get_instance();
$current_url = $CI->config->site_url($CI->uri->uri_string());
$this->session->set_flashdata('referrer', $current_url);
$this->layout = new HC_View_Layout();
}
示例5: index
function index()
{
$args = hc_parse_args(func_get_args(), TRUE);
if (!isset($args['id'])) {
echo 'PARAMS MISSING IN admin/users/zoom/index<br>';
return;
}
/* PARAMS */
$id = $args['id'];
$tab = isset($args['tab']) ? $args['tab'] : 'edit';
$subtab = isset($args['subtab']) ? $args['subtab'] : '';
if (is_object($id)) {
$model = $id;
} else {
$model = HC_App::model('user');
$model->where('id', $id)->get();
$this->_check_model($model);
}
/* build content */
$subheader = NULL;
$content = '';
$method = '_content_' . $tab;
if (method_exists($this, $method)) {
$content = $this->{$method}($model);
} else {
$extensions = HC_App::extensions();
if ($extensions->has(array('admin/users/zoom', $tab))) {
$calling_parent = 'admin/users/zoom/index/id/' . $id . '/tab/' . $tab;
$pass_arg = isset($args['_pass']) ? $args['_pass'] : array();
array_unshift($pass_arg, array('admin/users/zoom', $tab, $calling_parent));
$pass_arg[] = 'user';
$pass_arg[] = $model->id;
$content = call_user_func_array(array($extensions, 'run'), $pass_arg);
$subheader = $extensions->run(array('admin/users/zoom/menubar', $tab), $model);
}
}
/* CONTENT */
$content = $this->render($this->views_path . '/index', array('subheader' => $subheader, 'content' => $content));
$this->layout->set_partial('content', $content);
/* HEADER */
$this->layout->set_partial('header_ajax', $this->render($this->views_path . '/_header', array('object' => $model)));
/* MENUBAR */
$this->layout->set_partial('sidebar', $this->render($this->views_path . '/_menubar', array('tab' => $tab, 'object' => $model)));
$this->layout();
}
示例6: index
function index()
{
if (!$this->auth->check()) {
$this->redirect('auth/login');
}
$args = hc_parse_args(func_get_args(), TRUE);
// if( ! (isset($args['id'])) ){
// echo 'PARAMS MISSING IN admin/users/zoom/index<br>';
// return;
// }
/* PARAMS */
$tab = isset($args['tab']) ? $args['tab'] : 'edit';
$model = isset($args['id']) ? $args['id'] : clone $this->auth->user();
/* build content */
$subheader = NULL;
$content = '';
$method = '_content_' . $tab;
if (method_exists($this, $method)) {
$content = $this->{$method}($model);
} else {
$extensions = HC_App::extensions();
if ($extensions->has(array('auth/profile', $tab))) {
$calling_parent = 'auth/profile/index/tab/' . $tab;
$pass_arg = isset($args['_pass']) ? $args['_pass'] : array();
array_unshift($pass_arg, array('auth/profile', $tab, $calling_parent));
$pass_arg[] = 'user';
$pass_arg[] = $model->id;
$content = call_user_func_array(array($extensions, 'run'), $pass_arg);
$subheader = $extensions->run(array('auth/profile/menubar', $tab), $model);
}
}
/* CONTENT */
$content = $this->render($this->views_path . '/index', array('subheader' => $subheader, 'content' => $content));
$this->layout->set_partial('content', $content);
/* HEADER */
$this->layout->set_partial('header_ajax', $this->render($this->views_path . '/_header', array('object' => $model)));
/* MENUBAR */
$this->layout->set_partial('sidebar', $this->render($this->views_path . '/_menubar', array('tab' => $tab, 'object' => $model)));
$this->layout();
}
示例7: foreach
}
/* TIME */
if ($templates_label) {
$time_input = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled')->add_attr('class', 'list-inline')->add_item('item', $form->input('time'))->add_item('label', $templates_label)->add_item_attr('label', 'style', 'margin-left: 1em;');
} else {
$time_input = $form->input('time');
}
$display_form->add_item(HC_Html_Factory::widget('grid')->add_item(HC_Html_Factory::widget('label_row')->set_label(HCM::__('Time'))->set_content($time_input)->set_error($form->input('time')->error()), 7)->add_item(HC_Html_Factory::widget('label_row')->set_label(HCM::__('Date'))->set_content($form->input('date'))->set_error($form->input('date')->error()), 5));
/* STAFF */
$display_form->add_item($form->input('user'));
$staff_view = HC_Html_Factory::widget('module')->set_url('shifts/zoom/form')->pass_arg($object)->pass_arg('user')->set_self_target(TRUE)->set_skip_src(TRUE);
$display_form->add_item(HC_Html_Factory::widget('label_row')->set_label(HCM::__('Staff'))->set_content($staff_view));
/* STATUS */
$display_form->add_item(HC_Html_Factory::widget('label_row')->set_label(HCM::__('Status'))->set_content($form->input('status')->set_inline(TRUE)->add_option($object->_const('STATUS_DRAFT'), $object->set('status', $object->_const('STATUS_DRAFT'))->present_status())->add_option($object->_const('STATUS_ACTIVE'), $object->set('status', $object->_const('STATUS_ACTIVE'))->present_status())->render())->set_error($form->input('status')->error()));
/* ADD NOTE IF POSSIBLE */
$extensions = HC_App::extensions();
$more_content = $extensions->run('shifts/zoom/confirm');
if ($more_content) {
$more_holder = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled')->add_attr('class', 'list-separated2');
foreach ($more_content as $mc) {
$more_holder->add_item($mc);
}
$display_form->add_item($more_holder);
}
$display_form->add_item(HC_Html_Factory::widget('label_row')->set_content($buttons)->add_attr('class', 'padded2')->add_attr('style', 'border-top: #eee 1px solid; margin-top: 1em;'));
// echo $display_form->render();
$out = HC_Html_Factory::widget('flatmodal');
$out->set_content($display_form);
/*
$out->set_closer(
HC_Html_Factory::element('a')
示例8: render
//.........这里部分代码省略.........
} else {
$a_link->add_attr('target', '_blank');
$a_link->add_attr('class', 'hc-parent-loader');
}
if ($nolink) {
$a_title = HC_Html_Factory::widget('titled', 'span');
} else {
$a_title = HC_Html_Factory::widget('titled', 'a');
}
$a_title = HC_Html_Factory::widget('titled', 'span');
$a_title->add_attr('class', array('squeeze-in'));
// $a_title->add_attr('style', 'border: red 1px solid;');
// $a_title->add_attr('style', 'border-color: ' . $sh->location->present_color());
if ($wide === 'mini') {
if (!$nolink) {
$final_ttl = clone $a_link;
$final_ttl->add_child(' ')->add_attr('style', 'display: block;');
$final_ttl->add_attr('title', join(' ', $titles));
}
$a_title->add_child($final_ttl);
} else {
if (count($display) > 1) {
if ($wide) {
$titles2 = HC_Html_Factory::widget('grid');
$titles2->set_slim();
$grid_width = array(2 => 6, 3 => 4, 4 => 3, 5 => 2, 6 => 2);
$grid_width = isset($grid_width[count($display)]) ? $grid_width[count($display)] : 2;
for ($ti = 0; $ti < count($titles); $ti++) {
$ttl = $titles[$ti];
// next title is empty?
if ($ti < count($titles) - 1 && !strlen($titles[$ti + 1])) {
$ti++;
$grid_width += $grid_width;
}
$final_ttl = $ttl;
if (!$nolink) {
$final_ttl = clone $a_link;
$final_ttl->add_child($ttl);
}
$titles2->add_item($final_ttl, $grid_width, array('class' => 'squeeze-in'));
}
} else {
$titles2 = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled');
$this_index = 0;
foreach ($titles as $ttl) {
if (!strlen($ttl)) {
continue;
}
$final_ttl = $ttl;
if (!$nolink) {
$final_ttl = clone $a_link;
$final_ttl->add_child($ttl);
}
$titles2->add_item($this_index, $final_ttl);
$titles2->add_item_attr($ttl, 'class', array('squeeze-in'));
$this_index++;
}
}
$a_title->add_attr('title', join(' ', $titles));
$a_title->add_child($titles2);
} else {
$final_ttl = $titles;
if (!$nolink) {
$final_ttl = clone $a_link;
$final_ttl->add_child($titles);
}
$final_ttl->add_attr('title', join(' ', $titles));
$a_title->add_child($final_ttl);
}
}
$wrap->add_child($a_title);
/* EXTENSIONS */
$extensions = HC_App::extensions();
$more_content = $extensions->set_skip($iknow)->run('shifts/quickview', $sh, $wrap);
if ($wide !== 'mini') {
if ($more_content) {
$more_wrap = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled')->add_attr('class', 'list-separated')->add_attr('class', 'text-small');
$added = 0;
foreach ($more_content as $mck => $mc) {
if ($mck && in_array($mck, $iknow)) {
continue;
}
$more_wrap->add_item($mc);
$added++;
}
if ($added) {
$wrap->add_child($more_wrap);
}
}
}
/* THIS CHILDREN */
if ($wide !== 'mini') {
$children = $this->children();
foreach ($children as $child) {
$wrap->add_child($child);
}
}
$wrap->add_attr('class', 'common-link-parent');
return $wrap->render();
}
示例9: index
function index()
{
$args = hc_parse_args(func_get_args(), TRUE);
if (!isset($args['id'])) {
echo 'PARAMS MISSING IN shifts/zoom/index<br>';
return;
}
/* PARAMS */
$id = $args['id'];
$tab = isset($args['tab']) ? $args['tab'] : 'overview';
$subtab = isset($args['subtab']) ? $args['subtab'] : '';
if (is_object($id)) {
$model = $id;
} else {
$model = HC_App::model('shift');
$model->where('id', $id)->get();
$this->_check_model($model);
}
$acl = HC_App::acl();
if (!$acl->set_object($model)->can('view')) {
return;
}
/* display form */
$this->form_edit->set_values($model->to_array());
$this->form_edit->set_errors($model->errors());
/* build content */
$calling_parent = 'shifts/zoom/index/id/' . $id;
$subheader = NULL;
$content = '';
$method = '_content_' . $tab;
if (method_exists($this, $method)) {
$content = $this->{$method}($model, $args);
} else {
$extensions = HC_App::extensions();
if ($extensions->has(array('shifts/zoom', $tab))) {
$calling_parent = 'shifts/zoom/index/id/' . $id . '/tab/' . $tab;
$content = $extensions->run(array('shifts/zoom', $tab, $calling_parent), $model, $subtab);
$subheader = $extensions->run(array('shifts/zoom/menubar', $tab), $model);
}
}
/* CONTENT */
$content = $this->render($this->views_path . '/index', array('subheader' => $subheader, 'content' => $content));
$this->layout->set_partial('content', $content);
if (!in_array($tab, array('assign'))) {
/* HEADER */
$this->layout->set_partial('header_ajax', $this->render($this->views_path . '/_header', array('object' => $model)));
/* MENUBAR */
$this->layout->set_partial('sidebar', $this->render($this->views_path . '/_menubar', array('tab' => $tab, 'object' => $model)));
}
$this->layout();
}
示例10: _init_shifts
//.........这里部分代码省略.........
if (is_array($this->fix['location']) && count($this->fix['location']) == 1 && $this->fix['location'][0] == 0) {
/* all locations */
} else {
$where_location = $this->fix['location'];
}
}
if (isset($state['location'])) {
if (!is_array($state['location'])) {
$state['location'] = array($state['location']);
}
$where_location = $state['location'];
}
if ($where_location) {
$shifts->group_start();
$shifts->or_where('type', $shifts->_const('TYPE_TIMEOFF'));
$shifts->or_where_in_related('location', 'id', $where_location);
$shifts->group_end();
}
/* staff */
$where_staff = array();
if ($this->fix['staff']) {
$where_staff = $this->fix['staff'];
}
if (isset($state['staff'])) {
if (!is_array($state['staff'])) {
$state['staff'] = array($state['staff']);
}
$where_staff = $state['staff'];
}
if (count($where_staff)) {
if (in_array(0, $where_staff)) {
$shifts->group_start();
$shifts->or_where_related('user', 'id', NULL, TRUE);
$shifts->or_where_related('user', 'id', 0);
$shifts->or_where_in_related('user', 'id', $where_staff);
$shifts->group_end();
} else {
$shifts->where_related('user', 'id', $where_staff);
}
}
/* type */
if (isset($this->fix['type'])) {
$state['type'] = $this->fix['type'];
}
if (isset($state['by']) && $state['by'] == 'location') {
$shifts->where('type', $shifts->_const('TYPE_SHIFT'));
}
if (isset($state['type']) && $state['type'] !== NULL) {
$this_types = array();
$this_statuses = array();
foreach ($state['type'] as $stype) {
if (strpos($stype, '_') === FALSE) {
$this_type = $stype;
$this_types[$this_type] = 1;
} else {
list($this_type, $this_status) = explode('_', $stype);
$this_types[$this_type] = 1;
$this_statuses[$this_status] = 1;
}
}
if ($this_types) {
$shifts->where_in('type', array_keys($this_types));
}
if ($this_statuses) {
$shifts->where_in('status', array_keys($this_statuses));
}
}
/* status */
if (isset($state['status'])) {
$shifts->where('status', $state['status']);
}
/* extensions */
$extensions = HC_App::extensions();
$current_filter = '';
if (isset($this->fix['filter'])) {
$current_filter = $this->fix['filter'];
} elseif (isset($state['filter'])) {
$current_filter = $state['filter'];
}
/* preprocess */
if ($current_filter) {
if ($extensions->has(array('list/filter', $current_filter))) {
$shifts = $extensions->run(array('list/filter', $current_filter), 'pre', $shifts);
}
}
/* NOW GET */
$shifts->get();
// $shifts->get_iterated();
// $shifts->check_last_query();
$acl = HC_App::acl();
$return = $acl->filter($shifts, 'view');
/* extensions with postprocess */
if ($current_filter) {
if ($extensions->has(array('list/filter', $current_filter))) {
$return = $extensions->run(array('list/filter', $current_filter), 'post', $return);
}
}
return $return;
// return $shifts;
}
示例11: api_insert
function api_insert($post, $parent = NULL)
{
$notes = $post['notes'];
$note = HC_App::model('note');
$note->content = $notes;
$relations = array('author' => $this->auth->user());
if ($parent) {
$relations[$parent->my_class()] = $parent;
}
if (isset($parent)) {
$access_levels = $this->access_levels;
if (count($access_levels) == 1) {
$access_levels = array_keys($access_levels);
$access_level = $access_levels[0];
} else {
$access_level = $post['access_level'];
}
} else {
$access_level = 0;
}
if (!$access_level) {
$access_level = 0;
}
$note->access_level = $access_level;
if ($note->save($relations)) {
$return = TRUE;
} else {
$return = $note->error->string;
}
/* extensions */
$extensions = HC_App::extensions();
$extensions->run('notes/insert', $post);
return $return;
}
示例12: insert
function insert()
{
$extensions = HC_App::extensions();
$params = $this->_init_add_params(func_get_args());
$params_array = $params->to_array();
$model = HC_App::model('shift');
$date_input = $this->form_add_time->input('date');
$date_input->set_value($params_array['date']);
$dates = $date_input->dates();
/* if post supplied */
$post = $this->input->post();
$this->form_confirm->grab($post);
$form_values = $this->form_confirm->values();
$possible_statuses = $params->get_options('status');
if (count($possible_statuses) > 1) {
if (array_key_exists('status', $form_values)) {
$params_array['status'] = $form_values['status'];
}
} elseif (count($possible_statuses) == 1) {
$params_array['status'] = array_shift($possible_statuses);
}
$success_count = 0;
$users_ids = $params_array['user'];
// $publish_now = ($form_values['status'] == $model->_const('STATUS_ACTIVE')) ? TRUE : FALSE;
$publish_now = $params_array['status'] == $model->_const('STATUS_ACTIVE') ? TRUE : FALSE;
unset($params_array['user']);
if (!$params_array['location']) {
unset($params_array['location']);
}
/* group id */
$group_id = 0;
if (count($dates) * count($users_ids) > 1) {
$max_group_id = $model->select_max('group_id')->get()->group_id;
if (!$max_group_id) {
$max_group_id = 0;
}
$group_id = $max_group_id + 1;
}
$result_models = array();
foreach ($dates as $date) {
foreach ($users_ids as $uid) {
$this_params = $params_array;
$this_params['date'] = $date;
if ($uid) {
$this_params['user'] = $uid;
}
$model->clear();
$related = $model->from_array($this_params);
$model->group_id = $group_id;
/* create shift */
if (!$model->save($related)) {
$errors = $model->errors();
$this->form_confirm->set_errors($errors);
$orphan_errors = $this->form_confirm->orphan_errors();
return $this->_add($params, 'confirm');
}
$success_count++;
$result_models[] = clone $model;
/* extensions */
$extensions->run('shifts/insert', $post, $model);
}
}
switch ($model->type) {
case $model->_const('TYPE_SHIFT'):
$msg = sprintf(HCM::_n('%d shift added', '%d shifts added', $success_count), $success_count);
break;
case $model->_const('TYPE_TIMEOFF'):
$msg = sprintf(HCM::_n('%d timeoff added', '%d timeoffs added', $success_count), $success_count);
break;
}
$this->session->set_flashdata('message', $msg);
$redirect_to = 'list/calendar';
$parent_refresh = array();
foreach ($result_models as $o) {
$this_parent_refresh = $o->present_calendar_refresh();
$parent_refresh = array_merge($parent_refresh, $this_parent_refresh);
}
$parent_refresh = array_keys($parent_refresh);
$this->redirect($redirect_to, $parent_refresh);
}
示例13: bulk
function bulk()
{
$acl = HC_App::acl();
$extensions = HC_App::extensions();
/* if post supplied */
$post = $this->input->post();
if (isset($post['id'])) {
$ids = $post['id'];
} elseif (isset($post['ids'])) {
$ids = explode('|', $post['ids']);
} else {
$ids = array();
}
// $action = isset($post['action']) ? $post['action'] : '';
// if( $ids && $action ){
if ($ids) {
$model = HC_App::model('shift');
$model->where_in('id', $ids)->get();
$success_count = 0;
$action = 'update';
/* delete */
if (isset($post['delete'])) {
$action = 'delete';
foreach ($model as $o) {
if (!$acl->set_object($o)->can('delete')) {
continue;
}
if ($o->delete()) {
$success_count++;
}
}
} else {
$this->form->grab($post);
$form_values = $this->form->values();
foreach ($model as $o) {
if (!$acl->set_object($o)->can('edit')) {
continue;
}
reset($form_values);
foreach ($form_values as $k => $v) {
if ($v === NULL) {
continue;
}
$o->{$k} = $v;
}
if ($o->save()) {
$success_count++;
} else {
$errors = $o->errors();
}
}
}
switch ($action) {
case 'delete':
$msg = sprintf(HCM::_n('%d shift deleted', '%d shifts deleted', $success_count), $success_count);
break;
default:
$msg = sprintf(HCM::_n('%d shift updated', '%d shifts updated', $success_count), $success_count);
break;
}
if ($msg) {
$this->session->set_flashdata('message', $msg);
}
foreach ($model as $o) {
$extensions->run('shifts/update', $post, $o);
}
}
$redirect_to = '-referrer-';
$parent_refresh = array();
foreach ($model as $o) {
$this_parent_refresh = $o->present_calendar_refresh();
$parent_refresh = array_merge($parent_refresh, $this_parent_refresh);
}
$parent_refresh = array_keys($parent_refresh);
$this->redirect($redirect_to, $parent_refresh);
}
示例14: send
public function send($key, $user, $payloads = array())
{
if (!$user->email) {
return;
}
$app_conf = HC_App::app_conf();
$conf_key = 'notifications_email:' . $key;
$subject = $app_conf->conf($conf_key);
if ($subject === FALSE) {
$subject = $key;
}
$msg = new stdClass();
$msg->subject = $subject;
if (count($payloads) > 1) {
$msg->subject .= ' (' . count($payloads) . ')';
}
$extensions = HC_App::extensions();
/* build body */
$body = array();
foreach ($payloads as $payload) {
foreach ($payload as $k => $obj) {
/*
$body = array_merge(
$body,
array_values($obj->present_text(HC_PRESENTER::VIEW_TEXT, TRUE))
);
*/
if (is_object($obj)) {
$body = array_merge($body, array_values($obj->present_text(HC_PRESENTER::VIEW_RAW, TRUE)));
} elseif (is_array($obj)) {
$body = array_merge($body, $obj);
} else {
}
// extensions
$ext_key = 'notifications_email' . '/' . $key;
$more_content = $extensions->run($ext_key, $obj, $user);
if ($more_content) {
$body[] = '';
}
/*
foreach( $more_content as $subtab => $subtext ){
if( $subtext ){
if( is_array($subtext) ){
foreach( $subtext as $subtext2 ){
if( is_array($subtext2) ){
$body = array_merge( $body, $subtext2 );
}
else {
$body[] = $subtext2;
}
}
}
else {
$body[] = $subtext;
}
}
}
*/
}
$body[] = '';
}
$msg->body = $body;
/* transport email */
$CI =& ci_get_instance();
$subj = $msg->subject;
$body = join("\n", $msg->body);
$CI->hc_email->setSubject($subj);
$CI->hc_email->setBody($body);
$CI->hc_email->sendToOne($user->email);
}
示例15: index
function index($id)
{
$extensions = HC_App::extensions();
$args = func_get_args();
$id = array_shift($args);
$model = HC_App::model('shift');
$model->where('id', $id)->get();
$this->_check_model($model);
$acl = HC_App::acl();
if (!$acl->set_object($model)->can('edit')) {
return;
}
$original_model = clone $model;
/* supplied as parameters */
$values = hc_parse_args($args);
/* if post supplied */
$form = $this->form_edit;
$post = $this->input->post();
if ($post) {
$form->grab($post);
$form_values = $form->values();
$values = array_merge($values, $form_values);
}
$relname = 'user';
$unassign = FALSE;
if ($values[$relname] === '0' or $values[$relname] === 0 or $values[$relname] == '' or $values[$relname] === NULL) {
// delete user relation
unset($values[$relname]);
if ($model->user_id) {
$unassign = TRUE;
}
}
if (!$values) {
return $this->_zoom($model, 'time');
}
if ($values['location'] === NULL) {
unset($values['location']);
}
$related = $model->from_array($values);
$action_result1 = $model->save($related);
$action_result2 = TRUE;
if ($unassign) {
$rel = $model->{$relname}->get();
$action_result2 = $model->delete($rel, $relname);
}
if ($action_result1 && $action_result2) {
/* extensions */
$extensions->run('shifts/update', $post, $model);
/* save and redirect here */
if ($id) {
$msg = sprintf(HCM::_n('%d shift updated', '%d shifts updated', 1), 1);
} else {
$msg = sprintf(HCM::_n('%d shift added', '%d shifts added', 1), 1);
}
$this->session->set_flashdata('message', $msg);
$redirect_to = 'shifts/zoom/index/id/' . $id;
// $redirect_to = '-referrer-';
/* what to refresh on referring page */
$parent_refresh = $model->present_calendar_refresh();
$parent_refresh = array_keys($parent_refresh);
$this->redirect($redirect_to, $parent_refresh);
} else {
/* final layout */
$this->layout->set_partial('content', Modules::run('shifts/zoom/index', 'id', $model));
$this->layout();
}
}