Skip to content

Commit

Permalink
* Remove desactived participant for views and forms.
Browse files Browse the repository at this point in the history
  • Loading branch information
porquero committed Aug 27, 2015
1 parent 1382993 commit 36a9029
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 194 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -9,4 +9,5 @@
/application/logs/
/_accounts/cc/
/application/config/database.php
/application/config/config.php
/application/config/config.php
/application/config/constants.php
27 changes: 20 additions & 7 deletions application/modules/account/controllers/participant.php
Expand Up @@ -26,7 +26,10 @@ function list_for_resume()
$result = array();

foreach ($participants as $participant) {
$result[] = (object) $this->read->json_content($participant);
$participant_info = (object) $this->read->json_content($participant);
if ($participant_info->active === TRUE) {
$result[] = $participant_info;
}
}

return $result;
Expand Down Expand Up @@ -82,15 +85,25 @@ public function list_for_context($context, $kind = 'context')

/**
* Get participants for account
*
* @param boolean $include_disabled Decides if include disabled participants.
*
* @return type
*/
public function list_for_account()
public function list_for_account($include_disabled = FALSE)
{
$this->load->module('file/read');
$participants = $this->read->files_basename(_INC_ROOT . '_accounts/' . $this->session->userdata('current_account') . '/_participants');
if ($include_disabled === TRUE) {
$this->load->module('file/read');
$result = $this->read->files_basename(_INC_ROOT . '_accounts/' . $this->session->userdata('current_account') . '/_participants');
}
else {
$participants = $this->list_for_resume();
foreach ($participants as $participant) {
$result[] = $participant->info['id'] . '.json';
}
}

return $participants;
return $result;
}

/**
Expand Down Expand Up @@ -290,7 +303,7 @@ public function all_people()

$where_in = array();

foreach ($this->list_for_account() as $participant) {
foreach ($this->list_for_account(TRUE) as $participant) {
$where_in[] = preg_replace('/\.json/', '', $participant);
}

Expand Down Expand Up @@ -380,7 +393,7 @@ public function invite()
public function info($username)
{
$this->load->model('cc/m_user');

return $this->m_user->data($username);
}

Expand Down
2 changes: 1 addition & 1 deletion application/modules/cc/models/m_user.php
Expand Up @@ -139,7 +139,7 @@ public function update($user, $data)
public function where_in($participants)
{
$result = array();
$participants = implode("','", $participants);
$participants = implode("','", (array) $participants);

$r = $this->db->select('username, name, email, ts')->from($this->_table_name)
->where('username in(\'' . $participants . '\')')->get();
Expand Down
8 changes: 2 additions & 6 deletions application/modules/cc/views/_inc/participants.phtml
Expand Up @@ -13,12 +13,7 @@ if (isset($participants) === TRUE && connected_user() !== FALSE):
<?php
foreach ($participants as $participant) {
$url = site_url('/account/participant/profile/' . trim($participant->info['id']));
if ($participant->active === TRUE) {
$username = $participant->info['id'];
}
else {
$username = '<strike>' . $participant->info['id'] . '</strike>';
}
$username = $participant->info['id'];

echo <<<PQR
<li><a href="{$url}" class="usr">{$username}</a></li>
Expand All @@ -29,4 +24,5 @@ PQR;
</div>
<div class="clear"></div>
<?php

endif;
56 changes: 28 additions & 28 deletions application/modules/cc/views/context/_inc/common_form.phtml
Expand Up @@ -5,37 +5,37 @@ echo $mode_edition === 'create' ? '<label class="no-margin"><span>' . lang('part
$label_responsible = '<label><span>' . lang('responsible') . '</span>';
// Only can set visibility on top context!
if (preg_replace('/\_*+' . $id . '$/', '', $context) === ''):
echo $mode_edition === 'create' ? Modules::run('account/participant/html_checkbox_for_account', 'participants', $context_participants) : NULL;
?>
<label class="no-margin"><span><?php echo lang('visibility'); ?></span></label>
<div class="checkbox">
<?php
$visibility = array(
'private' => FALSE,
'public' => FALSE,
);
if (isset($info['info']['visibility'])) {
$visibility[$info['info']['visibility']] = TRUE;
}
else {
$visibility['private'] = TRUE;
}
?>
<label><?php echo form_radio('visibility', 'private', $visibility['private']); ?> <span><?php echo lang('private'); ?></span></label>
<label><?php echo form_radio('visibility', 'public', $visibility['public']); ?> <span><?php echo lang('public'); ?></span></label>
<div class="clear"></div>
</div>
<?php
echo $label_responsible . Modules::run('account/participant/html_select_for_account', 'responsible', $responsible) . '</label>';
echo $mode_edition === 'create' ? Modules::run('account/participant/html_checkbox_for_account', 'participants', $context_participants) : NULL;
?>
<label class="no-margin"><span><?php echo lang('visibility'); ?></span></label>
<div class="checkbox">
<?php
$visibility = array(
'private' => FALSE,
'public' => FALSE,
);
if (isset($info['info']['visibility'])) {
$visibility[$info['info']['visibility']] = TRUE;
}
else {
$visibility['private'] = TRUE;
}
?>
<label><?php echo form_radio('visibility', 'private', $visibility['private']); ?> <span><?php echo lang('private'); ?></span></label>
<label><?php echo form_radio('visibility', 'public', $visibility['public']); ?> <span><?php echo lang('public'); ?></span></label>
<div class="clear"></div>
</div>
<?php
echo $label_responsible . Modules::run('account/participant/html_select_for_account', 'responsible', $responsible) . '</label>';
else:
echo $mode_edition === 'create' ? Modules::run('account/participant/html_checkbox_for_context', $context, 'participants', $context_participants) : NULL;
echo $label_responsible . Modules::run('account/participant/html_select_for_context', $context, 'responsible', $responsible) . '</label>';
echo $mode_edition === 'create' ? Modules::run('account/participant/html_checkbox_for_context', $context, 'participants', $context_participants) : NULL;
echo $label_responsible . Modules::run('account/participant/html_select_for_context', $context, 'responsible', $responsible) . '</label>';
endif;
?>
<hr />
<fieldset>
<legend><?php echo lang('config') ?></legend>
<label><input type="checkbox" value="1"<?php echo ( ! isset($info['info']['label_inherit']) || $info['info']['label_inherit'] === 1) ? 'checked="checked"' : '' ?> name="label_inherit" id="label_inherit" /> <span><?php echo lang('label_inherit') ?></span></label>
<label><span><?php echo lang('context_label'); ?></span><?php echo form_input('context_label', isset($info['info']['context_label']) ? $info['info']['context_label'] : '', 'maxlength="30"') ?></label>
<label><span><?php echo lang('topic_label'); ?></span><?php echo form_input('topic_label', isset($info['info']['topic_label']) ? $info['info']['topic_label'] : '', 'maxlength="30"') ?></label>
<legend><?php echo lang('config') ?></legend>
<label><input type="checkbox" value="1"<?php echo ( ! isset($info['info']['label_inherit']) || $info['info']['label_inherit'] === 1) ? 'checked="checked"' : '' ?> name="label_inherit" id="label_inherit" /> <span><?php echo lang('label_inherit') ?></span></label>
<label><span><?php echo lang('context_label'); ?></span><?php echo form_input('context_label', isset($info['info']['context_label']) ? $info['info']['context_label'] : '', 'maxlength="30"') ?></label>
<label><span><?php echo lang('topic_label'); ?></span><?php echo form_input('topic_label', isset($info['info']['topic_label']) ? $info['info']['topic_label'] : '', 'maxlength="30"') ?></label>
</fieldset>
4 changes: 2 additions & 2 deletions application/modules/cc/views/context/modify_form.phtml
Expand Up @@ -7,8 +7,8 @@ echo form_open('/cc/context/modify', $attributes);
<label><span>Title</span><input type="text" name="title" id="title" value="<?php echo $info['info']['title'] ?>" /></label>
<?php include dirname(__FILE__) . '/_inc/common_form.phtml'; ?>
<div class="argt">
<button type="submit" name="submit" value="cancel"><?php echo lang('cancel'); ?></button>
<button type="submit" value="<?php echo $mode_edition ?>"><?php echo $mode_edition ?></button>
<button type="submit" name="submit" value="cancel"><?php echo lang('cancel'); ?></button>
<button type="submit" value="<?php echo $mode_edition ?>"><?php echo $mode_edition ?></button>
</div>
<?php
echo form_close();

0 comments on commit 36a9029

Please sign in to comment.