removed unneeded code

This commit is contained in:
hyung-hwan 2016-01-16 18:35:28 +00:00
parent 9ddf187486
commit 0033c3da7c

View File

@ -234,150 +234,6 @@ class Wiki extends Controller
$data['message'] = ''; $data['message'] = '';
$data['project'] = $project; $data['project'] = $project;
if ($this->input->post('wiki'))
{
$wiki = new stdClass();
$wiki->projectid = $this->input->post('wiki_projectid');
if ($mode == 'update')
{
$wiki->name = $this->input->post('wiki_original_name');
$new_wiki_name = $this->input->post('wiki_name');
}
else
{
$wiki->name = $this->input->post('wiki_name');
$new_wiki_name = NULL;
}
$wiki->text = $this->input->post('wiki_text');
$wiki->columns = $this->input->post('wiki_columns');
$wiki->attachments = array();
$wiki->delete_attachments = array();
if ($this->form_validation->run())
{
// $new_wiki_name is not needed if it's not different from the orignal name
if ($mode == 'update' && $wiki->name == $new_wiki_name) $new_wiki_name = NULL;
$delatts = $this->input->post('wiki_delete_attachment');
if (!empty($delatts))
{
foreach ($delatts as $att)
{
$atpos = strpos ($att, '@');
if ($atpos === FALSE) continue;
$attinfo['name'] = $this->converter->HexToAscii(
substr ($att, 0, $atpos));
$attinfo['encname'] = $this->converter->HexToAscii(
substr ($att, $atpos + 1));
array_push (
$wiki->delete_attachments,
(object)$attinfo
);
}
}
$atts = $this->wikis->getAttachments (
$login['id'], $project, $wiki->name);
if ($atts === FALSE)
{
$data['wiki'] = $wiki;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($view_edit, $data);
return;
}
$wiki->attachments = $atts;
if (strpbrk ($wiki->name, CODEPOT_DISALLOWED_LETTERS_IN_WIKINAME) !== FALSE ||
(!is_null($new_wiki_name) && strpbrk ($new_wiki_name, CODEPOT_DISALLOWED_LETTERS_IN_WIKINAME) !== FALSE))
{
$data['message'] = $this->lang->line('WIKI_MSG_NAME_DISALLOWED_CHARS');
$data['wiki'] = $wiki;
$this->load->view ($view_edit, $data);
return;
}
if ($this->wikihelper->_is_reserved ($wiki->name, FALSE) ||
(!is_null($new_wiki_name) && $this->wikihelper->_is_reserved ($new_wiki_name, FALSE)))
{
$data['message'] = sprintf (
$this->lang->line('WIKI_MSG_RESERVED_WIKI_NAME'),
$wiki->name
);
$data['wiki'] = $wiki;
$this->load->view ($view_edit, $data);
}
else
{
list($ret,$extra) =
$this->_upload_attachments ('wiki_new_attachment');
if ($ret === FALSE)
{
$data['wiki'] = $wiki;
$data['message'] = $extra;
$this->load->view ($view_edit, $data);
return;
}
$wiki->new_attachments = $extra;
$result = ($mode == 'update')?
$this->wikis->update ($login['id'], $wiki, $new_wiki_name):
$this->wikis->create ($login['id'], $wiki);
if ($result === FALSE)
{
// delete uploaded attachments if database operation failed.
foreach ($extra as $att) @unlink ($att['fullencpath']);
$data['message'] = 'DATABASE ERROR';
$data['wiki'] = $wiki;
$this->load->view ($view_edit, $data);
}
else
{
// delete attachments after database operation
// as 'delete' is not easy to restore.
foreach ($wiki->delete_attachments as $att)
@unlink (CODEPOT_ATTACHMENT_DIR . "/{$att->encname}");
if ($mode == 'update' && !is_null($new_wiki_name))
{
// renamed. redirect to a newly named page.
redirect ("wiki/show/{$project->id}/" .
$this->converter->AsciiToHex($new_wiki_name));
}
else
{
redirect ("wiki/show/{$project->id}/" .
$this->converter->AsciiToHex($wiki->name));
}
}
}
}
else
{
if ($mode == 'update')
{
$atts = $this->wikis->getAttachments (
$login['id'], $project, $wiki->name);
if ($atts === FALSE)
{
$data['wiki'] = $wiki;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($view_edit, $data);
return;
}
$wiki->attachments = $atts;
}
$data['message'] = $this->lang->line('MSG_FORM_INPUT_INCOMPLETE');
$data['wiki'] = $wiki;
$this->load->view ($view_edit, $data);
}
}
else
{
if ($mode == 'update') if ($mode == 'update')
{ {
$wiki = $this->wikis->get ($login['id'], $project, $name); $wiki = $this->wikis->get ($login['id'], $project, $name);
@ -410,8 +266,6 @@ class Wiki extends Controller
$this->load->view ($view_edit, $data); $this->load->view ($view_edit, $data);
} }
} }
}
} }
function create ($projectid = '', $name = '') function create ($projectid = '', $name = '')