本文整理汇总了PHP中HC_App::model方法的典型用法代码示例。如果您正苦于以下问题:PHP HC_App::model方法的具体用法?PHP HC_App::model怎么用?PHP HC_App::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HC_App
的用法示例。
在下文中一共展示了HC_App::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
/* if post supplied */
$post = $this->input->post();
$values = array();
if ($post) {
$this->form_add->grab($post);
$form_values = $this->form_add->values();
$values = array_merge($values, $form_values);
}
$date_value = $this->form_add->input('date')->value(TRUE);
if ($date_value['recurring'] == 'single') {
$values['date_start'] = $date_value['datesingle'];
$values['date_end'] = $date_value['datesingle'];
$values['details'] = '';
} else {
$values['date_start'] = $date_value['datestart'];
$values['date_end'] = $date_value['dateend'];
$values['details'] = $this->form_add->input('date')->value(FALSE, TRUE);
}
unset($values['date']);
$model = HC_App::model('availability');
$related = $model->from_array($values);
$action_result = $model->save($related);
if ($action_result) {
$msg = HCM::__('Availability added');
$this->session->set_flashdata('message', $msg);
$redirect_to = $this->my_parent();
$this->redirect($redirect_to);
} else {
$this->form_add->set_errors($model->errors());
$this->layout->set_partial('content', $this->render('availability/add', array('form' => $this->form_add)));
$this->layout();
}
}
示例2: index
function index($object, $object_id = NULL)
{
if (is_object($object)) {
$object_class = $object->my_class();
$object_id = $object->id;
} else {
$object_class = $object;
$object = HC_App::model($object_class)->where('id', $object_id)->get();
}
/* load */
$model = HC_App::model('logaudit');
$acl = HC_App::acl();
if (!$acl->set_object($object)->can('history::view')) {
return;
}
$entries = $model->changes_by_time($object);
$objects = array();
foreach ($entries as $action_time => $obj_changes) {
foreach (array_keys($obj_changes) as $object_full_id) {
if (array_key_exists($object_full_id, $objects)) {
continue;
}
list($obj_class, $obj_id) = explode('.', $object_full_id);
$child_object = HC_App::model($obj_class)->get_by_id($obj_id);
if (!$acl->set_object($child_object)->can('view')) {
unset($entries[$action_time][$object_full_id]);
continue;
}
$objects[$object_full_id] = $child_object;
}
}
/* render view */
$this->layout->set_partial('content', $this->render('logaudit/index', array('object' => $object, 'objects' => $objects, 'entries' => $entries)));
$this->layout();
}
示例3: can
public function can($what, $params = array())
{
$return = FALSE;
$object = $this->object();
$user = $this->user();
if (!$user) {
$user = HC_App::model('user');
}
$check = array();
if ($object) {
$check[] = $object->my_class() . '::' . $object->id . '::' . $what;
$check[] = $object->my_class() . '::' . '*' . '::' . $what;
$check[] = $object->my_class() . '::' . $what;
$check[] = $object->my_class() . '::' . '*';
}
$check[] = $what;
$check[] = '*';
reset($check);
foreach ($check as $ch) {
if (isset($this->rules[$ch])) {
$rule = $this->rules[$ch];
if (is_callable($rule)) {
$return = $rule($user, $object, $params);
} else {
$return = $rule;
}
if ($return !== NULL) {
break;
}
}
}
return $return;
}
示例4: insert
function insert()
{
$model = HC_App::model('user');
/* supplied as parameters */
$args = func_get_args();
$values = hc_parse_args($args);
/* if post supplied */
$post = $this->input->post();
if ($post) {
$this->forms['add']->grab($post);
$post = $this->forms['add']->values();
$values = array_merge($values, $post);
}
if (!$values) {
$redirect_to = 'admin/users/add';
$this->redirect($redirect_to);
return;
}
$related = $model->from_array($values);
if ($model->save($related)) {
/* save and redirect here */
$msg = HCM::__('User added');
$this->session->set_flashdata('message', $msg);
$redirect_to = 'admin/users/index';
$this->redirect($redirect_to);
} else {
/* final layout */
$this->layout->set_partial('content', Modules::run('admin/users/add/index', $model));
$this->layout();
}
}
示例5: index
function index()
{
$args = hc_parse_args(func_get_args(), TRUE);
if (!isset($args['id'])) {
echo 'PARAMS MISSING IN availability/delete<br>';
return;
}
$id = $args['id'];
$model = HC_App::model('availability');
$model->where('id', $id)->get();
$this->_check_model($model);
$acl = HC_App::acl();
if (!$acl->set_object($model)->can('delete')) {
return;
}
/* what to refresh on referring page */
$parent_refresh = $model->present_calendar_refresh();
$parent_refresh = array_keys($parent_refresh);
if ($model->delete()) {
$this->session->set_flashdata('message', HCM::__('Availability deleted'));
} else {
$this->session->set_flashdata('error', HCM::__('Error'));
}
$redirect_to = $this->my_parent();
$this->redirect($redirect_to, $parent_refresh);
}
示例6: _update
private function _update($tab, $args)
{
$id = array_shift($args);
$model = HC_App::model('user');
$model->where('id', $id)->get();
$this->_check_model($model);
$original_model = clone $model;
/* supplied as parameters */
$values = hc_parse_args($args);
/* if post supplied */
$post = $this->input->post();
if ($post) {
$this->forms[$tab]->grab($post);
$post = $this->forms[$tab]->values();
$values = array_merge($values, $post);
}
if (!$values) {
$redirect_to = 'admin/users/zoom/index/id/' . $id . '/tab/' . $tab;
$this->redirect($redirect_to);
return;
}
$related = $model->from_array($values);
if ($model->save($related)) {
/* save and redirect here */
$msg = HCM::__('User updated');
$this->session->set_flashdata('message', $msg);
$redirect_to = 'admin/users/zoom/index/id/' . $id . '/tab/' . $tab;
$this->redirect($redirect_to);
} else {
/* final layout */
$this->layout->set_partial('content', Modules::run('admin/users/zoom/index', 'id', $model, 'tab', $tab));
$this->layout();
}
}
示例7: index
public function index()
{
$app = $this->config->item('nts_app');
$app_conf = HC_App::app_conf();
if (isset($GLOBALS['NTS_CONFIG'][$app]['FORCE_LOGIN_ID'])) {
$id = $GLOBALS['NTS_CONFIG'][$app]['FORCE_LOGIN_ID'];
$this->auth->login($id);
}
// sync user account
$ri = $this->remote_integration();
if ($ri) {
$id = $this->auth->check();
if ($id) {
$model_name = $ri . '_User';
$um = HC_App::model($model_name);
$um->sync($id);
$this->auth->reset_user();
}
}
// check user level
$user_level = 0;
$user_id = 0;
if ($this->auth->check()) {
if ($test_user = $this->auth->user()) {
$user_id = $test_user->id;
$user_level = $test_user->level;
}
}
if ($ri) {
$wall_schedule_display = 0;
} else {
$wall_schedule_display = $app_conf->get('wall:schedule_display');
}
$default_params = $this->default_params;
$allowed = FALSE;
switch ($user_level) {
case 0:
if ($wall_schedule_display <= $user_level) {
$to = 'list';
} else {
if ($user_id) {
$to = 'auth/notallowed';
} else {
$to = 'auth/login';
}
}
break;
case USER_HC_MODEL::LEVEL_ADMIN:
case USER_HC_MODEL::LEVEL_MANAGER:
$to = isset($default_params['route']) ? $default_params['route'] : 'list';
break;
case USER_HC_MODEL::LEVEL_STAFF:
$to = isset($default_params['route']) ? $default_params['route'] : 'listme';
break;
}
$this->redirect($to);
exit;
}
示例8: index
public function index()
{
$args = hc_parse_args(func_get_args(), TRUE);
if (!isset($args['id'])) {
echo 'PARAMS MISSING IN availability/update/index<br>';
return;
}
$id = $args['id'];
if (is_object($id)) {
$model = $id;
} else {
$model = HC_App::model('availability');
$model->where('id', $id)->get();
$this->_check_model($model);
}
$acl = HC_App::acl();
if (!$acl->set_object($model)->can('edit')) {
return;
}
// $values = hc_parse_args( $args );
$values = array();
$form = $this->form_edit;
$post = $this->input->post();
if ($post) {
$form->grab($post);
$form_values = $form->values();
$values = array_merge($values, $form_values);
}
$date_value = $form->input('date')->value(TRUE);
if ($date_value['recurring'] == 'single') {
$values['date_start'] = $date_value['datesingle'];
$values['date_end'] = $date_value['datesingle'];
$values['details'] = '';
} else {
$values['date_start'] = $date_value['datestart'];
$values['date_end'] = $date_value['dateend'];
$values['details'] = $form->input('date')->value(FALSE, TRUE);
}
unset($values['date']);
$related = $model->from_array($values);
// $action_result = $model->save( $related );
$action_result = $model->save();
if ($action_result) {
$msg = HCM::__('Availability updated');
$this->session->set_flashdata('message', $msg);
$redirect_to = $this->my_parent();
$redirect_to .= '/user/' . $model->user_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 {
$form->set_errors($model->errors());
$this->layout->set_partial('content', $this->render('availability/zoom/index', array('form' => $form, 'object' => $model)));
$this->layout();
}
}
示例9: get
function get($model)
{
/* if the shift within the preferred availability */
$myclass = get_class();
$return = array();
if ($model->type == $model->_const('TYPE_TIMEOFF')) {
return $return;
}
if (!(strlen($model->start) && strlen($model->end))) {
return $return;
}
if (!($model->date && $model->date_end)) {
return $return;
}
if (!$model->user_id) {
return $return;
}
$am = HC_App::model('availability');
$am->where_related('user', 'id', $model->user_id)->where('type', $am->_const('TYPE_PREFERRED'))->where('date_end >=', $model->date)->where('date_start <=', $model->date_end);
$am->get_iterated_slim();
$found_availability = FALSE;
foreach ($am as $availability) {
/* get dates of this availability */
$this_dates = $availability->get_dates();
foreach ($this_dates as $this_date) {
$test = HC_App::model('shift');
$test->date = $this_date;
$test->start = $availability->start;
$test->end = $availability->end;
$test->validate();
if ($test->date_end < $model->date) {
continue;
}
if ($test->date > $model->date_end) {
break;
}
if ($test->covers($model)) {
$found_availability = TRUE;
break;
}
}
if ($found_availability) {
break;
}
}
if (!$found_availability) {
$conflict = new $myclass();
$conflict_id = array($model->id);
sort($conflict_id);
$conflict_id = $this->type . '_' . join('_', $conflict_id);
$conflict->id = $conflict_id;
$conflict->shift_id = $model->id;
// $conflict->details = $availability->id;
$return[] = $conflict;
}
return $return;
}
示例10: api_insert
function api_insert($post)
{
$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');
}
$return = TRUE;
return $return;
}
示例11: render
function render()
{
$model = HC_App::model('location');
$model->get();
$options = array();
foreach ($model as $obj) {
$options[$obj->id] = $obj->present_title();
}
$this->set_options($options);
return parent::render();
}
示例12: __construct
function __construct()
{
parent::__construct();
$this->rootlink = 'list_toff';
$temp_shift = HC_App::model('shift');
// $this->fix['staff'] = array( $this->auth->user()->id );
// $this->fix['location'] = array( 0 );
// $this->fix['filter'] = NULL;
$this->fix['type'] = array($temp_shift->_const('TYPE_TIMEOFF'));
$this->fix['tab'] = 'browse';
$this->default_params['range'] = 'upcoming';
}
示例13: run
public function run($msgs)
{
reset($msgs);
foreach ($msgs as $uid => $user_msgs) {
$user = HC_App::model('user')->where('id', $uid)->get();
/* group messages */
reset($user_msgs);
foreach ($user_msgs as $key => $payloads) {
$this->send($key, $user, $payloads);
}
}
}
示例14: todo
function todo()
{
$shifts = HC_App::model('shift')->where('release_request', 1);
$shifts->get();
$count = $shifts->result_count();
if (!$count) {
return;
}
/* render view */
$this->layout->set_partial('content', $this->render('release/todo', array('count' => $count)));
$this->layout();
}
示例15: 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;
}