diff --git a/codepot/src/codepot/controllers/file.php b/codepot/src/codepot/controllers/file.php index a56d5461..f1e45efc 100644 --- a/codepot/src/codepot/controllers/file.php +++ b/codepot/src/codepot/controllers/file.php @@ -230,13 +230,15 @@ class File extends Controller } else { - force_download ($name, $data); + force_download ($name, $data); } */ } } } +/* +// DEPRECATED function update ($projectid = '', $name = '') { $this->load->helper ('form'); @@ -288,6 +290,7 @@ class File extends Controller if ($this->input->post('file')) { + $file = new stdClass(); $file->name = $this->input->post('file_name'); $file->tag = $this->input->post('file_tag'); $file->description = $this->input->post('file_description'); @@ -334,6 +337,7 @@ class File extends Controller } } } +*/ function xhr_import ($projectid = '') { @@ -602,6 +606,72 @@ class File extends Controller print $status; } + function xhr_update ($projectid = '', $name = '') + { + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('FileModel', 'files'); + + $login = $this->login->getUser (); + + if ($login['id'] == '') + { + $status = 'error - anonymous user'; + } + else + { + $name = $this->converter->HexToAscii ($name); + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $status = "error - failed to get the project {$projectid}"; + } + else if ($project === NULL) + { + $status = "error - no such project {$projectid}"; + } + else if (!$login['sysadmin?'] && + $this->projects->projectHasMember($projectid, $login['id']) === FALSE) + { + $status = "error - not a member {$login['id']}"; + } + else + { + $file = new stdClass(); + $file->name = $this->input->post('file_edit_name'); + $file->tag = $this->input->post('file_edit_tag'); + $file->description = $this->input->post('file_edit_description'); + + + if ($file->name === FALSE || ($file->name = trim($file->name)) == '') + { + $status = 'error - no name'; + } + else if ($file->tag === FALSE || ($file->tag = trim($file->tag)) == '') + { + $status = 'error - no tag'; + } + else if ($file->description === FALSE || ($file->description = trim($file->description)) == '') + { + $status = 'error - no description'; + } + else + { + if ($this->files->update ($login['id'], $projectid, $name, $file) === FALSE) + { + $status = 'error - ' . $this->files->getErrorMessage(); + } + else + { + $status = 'ok'; + } + } + } + } + + print $status; + } + function xhr_delete ($projectid = '', $name = '') { $this->load->model ('ProjectModel', 'projects'); diff --git a/codepot/src/codepot/controllers/issue.php b/codepot/src/codepot/controllers/issue.php index 92764bae..7c0b52fa 100644 --- a/codepot/src/codepot/controllers/issue.php +++ b/codepot/src/codepot/controllers/issue.php @@ -918,7 +918,100 @@ DEPRECATED print $status; } - private function _handle_file ($login, $projectid, $issueid, $filename) + //////////////////////////////////////////////////////////////////////// + // Handling of attached files share the (almost) same code + // between issue.php and wiki.php. It would be way better + // to put the common code into a parent class and use inheritance. + // Makre sure to apply changes to both files if any. + + private function _handle_wiki_attachment ($login, $projectid, $wikiname, $name) + { + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('WikiModel', 'wikis'); + + $data['login'] = $login; + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_PROJECT') . + " - {$projectid}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + if ($project->public !== 'Y' && $login['id'] == '') + { + // non-public projects require sign-in. + redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); + } + + $att = $this->wikis->getAttachment ($login['id'], $project, $wikiname, $name); + if ($att === FALSE) + { + $data['project'] = $project; + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($att === NULL) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_NO_SUCH_FILE'), $name); + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $path = CODEPOT_ATTACHMENT_DIR . "/{$att->encname}"; + + $stat = @stat($path); + if ($stat === FALSE) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_FAILED_TO_READ_FILE'), $name); + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + + $etag = sprintf ('%x-%x-%x-%x', $stat['dev'], $stat['ino'], $stat['size'], $stat['mtime']); + $lastmod = gmdate ('D, d M Y H:i:s', $stat['mtime']); + + header ('Last-Modified: ' . $lastmod . ' GMT'); + header ('Etag: ' . $etag); + + if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) || + (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime'])) + { + header('Not Modified', true, 304); + flush (); + return; + } + + header ('Content-Type: ' . mime_content_type($path)); + header ('Content-Length: ' . $stat['size']); + header ('Content-Disposition: inline; filename=' . $name); + flush (); + + $x = @readfile($path); + if ($x === FALSE) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_FAILED_TO_READ_FILE'), $name); + $this->load->view ($this->VIEW_ERROR, $data); + } + } + } + } + + private function _handle_issue_file ($login, $projectid, $issueid, $filename) { $this->load->model ('ProjectModel', 'projects'); $this->load->model ('IssueModel', 'issues'); @@ -957,7 +1050,7 @@ DEPRECATED { $data['project'] = $project; $data['message'] = sprintf ( - $this->lang->line('ISSUE_MSG_NO_SUCH_FILE'), $filename); + $this->lang->line('MSG_NO_SUCH_FILE'), $filename); $this->load->view ($this->VIEW_ERROR, $data); } else @@ -969,7 +1062,7 @@ DEPRECATED { $data['project'] = $project; $data['message'] = sprintf ( - $this->lang->line('issue_MSG_FAILED_TO_READ_FILE'), $filename); + $this->lang->line('MSG_FAILED_TO_READ_FILE'), $filename); $this->load->view ($this->VIEW_ERROR, $data); return; } @@ -998,7 +1091,7 @@ DEPRECATED { $data['project'] = $project; $data['message'] = sprintf ( - $this->lang->line('ISSUE_MSG_FAILED_TO_READ_FILE'), $filename); + $this->lang->line('MSG_FAILED_TO_READ_FILE'), $filename); $this->load->view ($this->VIEW_ERROR, $data); } } @@ -1007,6 +1100,11 @@ DEPRECATED function file ($projectid = '', $issueid = '', $filename = '') { + // this function is for handling a file name for the following format: + // 1. filename + // 2. projectid:issueid:filename + // 3. projectid:wikiname:filename + // $login = $this->login->getUser (); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); @@ -1021,40 +1119,30 @@ DEPRECATED $filename = $this->converter->HexToAscii ($filename); + $wikiname = ''; $part = explode (':', $filename); if (count($part) == 3) { if ($part[0] != '') $projectid = $part[0]; - if ($part[1] != '') $issueid = $part[1]; + if ($part[1] != '') + { + if ($part[1][0] == '#' && $part[1][1] == 'I') + { + $issueid = substr ($part[1],2); + $wikiname = ''; + } + else + { + $wikiname = $part[1]; + $issueid = ''; + } + } if ($part[2] != '') $filename = $part[2]; } - $this->_handle_file ($login, $projectid, $issueid, $filename); - } - - - function file0 ($projectid = '', $target = '') - { - //$target => projectid:issueid:filename - - $login = $this->login->getUser (); - if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') - redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); - - if ($target == '') - { - $data['login'] = $login; - $data['message'] = 'INVALID PARAMETERS'; - $this->load->view ($this->VIEW_ERROR, $data); - return; - } - - $target = $this->converter->HexToAscii ($target); - $part = explode (':', $target); - if (count($part) == 3) - { - if ($part[0] == '') $part[0] = $projectid; - $this->_handle_attachment ($login, $part[0], $part[1], $part[2]); - } + if ($wikiname != '') + $this->_handle_wiki_attachment ($login, $projectid, $wikiname, $filename); + else + $this->_handle_issue_file ($login, $projectid, $issueid, $filename); } } diff --git a/codepot/src/codepot/controllers/wiki.php b/codepot/src/codepot/controllers/wiki.php index 6343d2dd..617304f2 100644 --- a/codepot/src/codepot/controllers/wiki.php +++ b/codepot/src/codepot/controllers/wiki.php @@ -175,147 +175,6 @@ class Wiki extends Controller $this->_show_wiki ($projectid, $name, FALSE); } - function attachment0 ($projectid = '', $target = '') - { - //$target => projectid:wikiname:attachment - - $login = $this->login->getUser (); - if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') - redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); - - if ($target == '') - { - $data['login'] = $login; - $data['message'] = 'INVALID PARAMETERS'; - $this->load->view ($this->VIEW_ERROR, $data); - return; - } - - $target = $this->converter->HexToAscii ($target); - $part = explode (':', $target); - if (count($part) == 3) - { - if ($part[0] == '') $part[0] = $projectid; - $this->_handle_attachment ($login, $part[0], $part[1], $part[2]); - } - } - - function attachment ($projectid = '', $wikiname = '', $name = '') - { - $login = $this->login->getUser (); - if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') - redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); - - - if ($wikiname == '' || $name == '') - { - $data['login'] = $login; - $data['message'] = 'INVALID PARAMETERS'; - $this->load->view ($this->VIEW_ERROR, $data); - return; - } - - $wikiname = $this->converter->HexToAscii ($wikiname); - $name = $this->converter->HexToAscii ($name); - - $part = explode (':', $name); - if (count($part) == 3) - { - if ($part[0] != '') $projectid = $part[0]; - if ($part[1] != '') $wikiname = $part[1]; - if ($part[2] != '') $name = $part[2]; - } - - $this->_handle_attachment ($login, $projectid, $wikiname, $name); - } - - private function _handle_attachment ($login, $projectid, $wikiname, $name) - { - $this->load->model ('ProjectModel', 'projects'); - $this->load->model ('WikiModel', 'wikis'); - - $data['login'] = $login; - - $project = $this->projects->get ($projectid); - if ($project === FALSE) - { - $data['message'] = 'DATABASE ERROR'; - $this->load->view ($this->VIEW_ERROR, $data); - } - else if ($project === NULL) - { - $data['message'] = - $this->lang->line('MSG_NO_SUCH_PROJECT') . - " - {$projectid}"; - $this->load->view ($this->VIEW_ERROR, $data); - } - else - { - if ($project->public !== 'Y' && $login['id'] == '') - { - // non-public projects require sign-in. - redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); - } - - $att = $this->wikis->getAttachment ($login['id'], $project, $wikiname, $name); - if ($att === FALSE) - { - $data['project'] = $project; - $data['message'] = 'DATABASE ERROR'; - $this->load->view ($this->VIEW_ERROR, $data); - } - else if ($att === NULL) - { - $data['project'] = $project; - $data['message'] = sprintf ( - $this->lang->line('WIKI_MSG_NO_SUCH_ATTACHMENT'), $name); - $this->load->view ($this->VIEW_ERROR, $data); - } - else - { - $path = CODEPOT_ATTACHMENT_DIR . "/{$att->encname}"; - - $stat = @stat($path); - if ($stat === FALSE) - { - $data['project'] = $project; - $data['message'] = sprintf ( - $this->lang->line('WIKI_MSG_FAILED_TO_READ_ATTACHMENT'), $name); - $this->load->view ($this->VIEW_ERROR, $data); - return; - } - - $etag = sprintf ('%x-%x-%x-%x', $stat['dev'], $stat['ino'], $stat['size'], $stat['mtime']); - $lastmod = gmdate ('D, d M Y H:i:s', $stat['mtime']); - - header ('Last-Modified: ' . $lastmod . ' GMT'); - header ('Etag: ' . $etag); - - if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) || - (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime'])) - { - header('Not Modified', true, 304); - flush (); - return; - } - - header ('Content-Type: ' . mime_content_type($path)); - header ('Content-Length: ' . $stat['size']); - header ('Content-Disposition: inline; filename=' . $name); - flush (); - - $x = @readfile($path); - if ($x === FALSE) - { - $data['project'] = $project; - $data['message'] = sprintf ( - $this->lang->line('WIKI_MSG_FAILED_TO_READ_ATTACHMENT'), $name); - $this->load->view ($this->VIEW_ERROR, $data); - } - } - } - } - function _edit_wiki ($projectid, $name, $mode) { $this->load->helper ('form'); @@ -377,6 +236,7 @@ class Wiki extends Controller if ($this->input->post('wiki')) { + $wiki = new stdClass(); $wiki->projectid = $this->input->post('wiki_projectid'); if ($mode == 'update') { @@ -542,6 +402,7 @@ class Wiki extends Controller } else { + $wiki = new stdClass(); $wiki->projectid = $projectid; $wiki->name = $name; $wiki->text = ''; @@ -623,6 +484,7 @@ class Wiki extends Controller if($this->input->post('wiki')) { + $wiki = new stdClass(); $wiki->projectid = $this->input->post('wiki_projectid'); $wiki->name = $this->input->post('wiki_name'); $data['wiki_confirm'] = $this->input->post('wiki_confirm'); @@ -738,4 +600,262 @@ class Wiki extends Controller return array(TRUE,$attachments); } + + /////////////////////////////////////////////////////////////////////// + // Handling of attached files share the (almost) same code + // between issue.php and wiki.php. It would be way better + // to put the common code into a parent class and use inheritance. + // Makre sure to apply changes to both files if any. + + private function _handle_wiki_attachment ($login, $projectid, $wikiname, $name) + { + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('WikiModel', 'wikis'); + + $data['login'] = $login; + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_PROJECT') . + " - {$projectid}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + if ($project->public !== 'Y' && $login['id'] == '') + { + // non-public projects require sign-in. + redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); + } + + $att = $this->wikis->getAttachment ($login['id'], $project, $wikiname, $name); + if ($att === FALSE) + { + $data['project'] = $project; + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($att === NULL) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_NO_SUCH_FILE'), $name); + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $path = CODEPOT_ATTACHMENT_DIR . "/{$att->encname}"; + + $stat = @stat($path); + if ($stat === FALSE) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_FAILED_TO_READ_FILE'), $name); + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + + $etag = sprintf ('%x-%x-%x-%x', $stat['dev'], $stat['ino'], $stat['size'], $stat['mtime']); + $lastmod = gmdate ('D, d M Y H:i:s', $stat['mtime']); + + header ('Last-Modified: ' . $lastmod . ' GMT'); + header ('Etag: ' . $etag); + + if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) || + (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime'])) + { + header('Not Modified', true, 304); + flush (); + return; + } + + header ('Content-Type: ' . mime_content_type($path)); + header ('Content-Length: ' . $stat['size']); + header ('Content-Disposition: inline; filename=' . $name); + flush (); + + $x = @readfile($path); + if ($x === FALSE) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_FAILED_TO_READ_FILE'), $name); + $this->load->view ($this->VIEW_ERROR, $data); + } + } + } + } + + private function _handle_issue_file ($login, $projectid, $issueid, $filename) + { + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('IssueModel', 'issues'); + + $data['login'] = $login; + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_PROJECT') . + " - {$projectid}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + if ($project->public !== 'Y' && $login['id'] == '') + { + // non-public projects require sign-in. + redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); + } + + $att = $this->issues->getFile ($login['id'], $project, $issueid, $filename); + if ($att === FALSE) + { + $data['project'] = $project; + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($att === NULL) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_NO_SUCH_FILE'), $filename); + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $path = CODEPOT_ISSUE_FILE_DIR . "/{$att->encname}"; + + $stat = @stat($path); + if ($stat === FALSE) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_FAILED_TO_READ_FILE'), $filename); + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + + $etag = sprintf ('%x-%x-%x-%x', $stat['dev'], $stat['ino'], $stat['size'], $stat['mtime']); + $lastmod = gmdate ('D, d M Y H:i:s', $stat['mtime']); + + header ('Last-Modified: ' . $lastmod . ' GMT'); + header ('Etag: ' . $etag); + + if ((isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) || + (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime'])) + { + header('Not Modified', true, 304); + flush (); + return; + } + + header ('Content-Type: ' . mime_content_type($path)); + header ('Content-Length: ' . $stat['size']); + header ('Content-Disposition: inline; filename=' . $filename); + flush (); + + $x = @readfile($path); + if ($x === FALSE) + { + $data['project'] = $project; + $data['message'] = sprintf ( + $this->lang->line('MSG_FAILED_TO_READ_FILE'), $filename); + $this->load->view ($this->VIEW_ERROR, $data); + } + } + } + } + + function attachment0 ($projectid = '', $target = '') + { + //$target => projectid:wikiname:attachment + //$target => projectid:#I1:file + + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); + + if ($target == '') + { + $data['login'] = $login; + $data['message'] = 'INVALID PARAMETERS'; + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + + $target = $this->converter->HexToAscii ($target); + $part = explode (':', $target); + if (count($part) == 3) + { + if ($part[0] == '') $part[0] = $projectid; + if ($part[1][0] == '#' && $part[1][1] == 'I') + { + $issueid = substr ($part[1],2); + $this->_handle_issue_file ($login, $part[0], $issueid, $part[2]); + } + else + { + $this->_handle_wiki_attachment ($login, $part[0], $part[1], $part[2]); + } + } + } + + function attachment ($projectid = '', $wikiname = '', $filename = '') + { + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); + + if ($wikiname == '' || $filename == '') + { + $data['login'] = $login; + $data['message'] = 'INVALID PARAMETERS'; + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + + $wikiname = $this->converter->HexToAscii ($wikiname); + $filename = $this->converter->HexToAscii ($filename); + + $part = explode (':', $filename); + if (count($part) == 3) + { + if ($part[0] != '') $projectid = $part[0]; + if ($part[1] != '') + { + if ($part[1][0] == '#' && $part[1][1] == 'I') + { + $issueid = substr ($part[1],2); + $wikiname = ''; + } + else + { + $wikiname = $part[1]; + $issueid = ''; + } + } + if ($part[2] != '') $filename = $part[2]; + } + + if ($wikiname != '') + $this->_handle_wiki_attachment ($login, $projectid, $wikiname, $filename); + else + $this->_handle_issue_file ($login, $projectid, $issueid, $filename); + } + } diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index 2471475f..99b5efe0 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -126,6 +126,8 @@ $lang['MSG_NO_DIFF'] = 'No difference found'; $lang['MSG_NO_CODE_AVAIL'] = 'No source code available'; $lang['MSG_NO_SUCH_PROJECT'] = 'No such project'; $lang['MSG_SURE_TO_DELETE_THIS'] = "I'm sure to delete this"; +$lang['MSG_FAILED_TO_READ_FILE'] = 'Failed to read file - %s'; +$lang['MSG_NO_SUCH_FILE'] = 'No such file - %s'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete'; diff --git a/codepot/src/codepot/language/english/wiki_lang.php b/codepot/src/codepot/language/english/wiki_lang.php index 53973ad2..a7007382 100644 --- a/codepot/src/codepot/language/english/wiki_lang.php +++ b/codepot/src/codepot/language/english/wiki_lang.php @@ -4,10 +4,8 @@ $lang['WIKI_NEW_ATTACHMENTS'] = 'New attachments'; $lang['WIKI_MORE_NEW_ATTACHMENTS'] = 'Add more'; $lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = 'Attachment name containing a colon'; -$lang['WIKI_MSG_FAILED_TO_READ_ATTACHMENT'] = 'Failed to read wiki attachment - %s'; $lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = 'Wiki name contains disallowed characters'; $lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = 'No wiki pages available'; $lang['WIKI_MSG_NO_SUCH_PAGE'] = 'No such wiki page - %s'; -$lang['WIKI_MSG_NO_SUCH_ATTACHMENT'] = 'No such wiki attachment - %s'; $lang['WIKI_MSG_RESERVED_WIKI_NAME'] = 'Wiki name containing a reserved word - %s'; ?> diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index 92e218a2..6e586b10 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -123,6 +123,8 @@ $lang['MSG_NO_DIFF'] = 'Tidak ada bedanya'; $lang['MSG_NO_CODE_AVAIL'] = 'Tidak ada kode sumber tersedia'; $lang['MSG_NO_SUCH_PROJECT'] = 'No such project'; $lang['MSG_SURE_TO_DELETE_THIS'] = "Saya yakin untuk menghapus"; +$lang['MSG_FAILED_TO_READ_FILE'] = 'Failed to read file - %s'; +$lang['MSG_NO_SUCH_FILE'] = 'No such file - %s'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index 2b077c61..c33d886c 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -126,6 +126,8 @@ $lang['MSG_NO_DIFF'] = '차이점이 없습니다'; $lang['MSG_NO_CODE_AVAIL'] = '소스코드가 없습니다'; $lang['MSG_NO_SUCH_PROJECT'] = '프로젝트가 없습니다'; $lang['MSG_SURE_TO_DELETE_THIS'] = '반드시 이것을 삭제하고 싶어요'; +$lang['MSG_FAILED_TO_READ_FILE'] = '파일을 읽을 수 없습니다 - %s'; +$lang['MSG_NO_SUCH_FILE'] = '파일이 없습니다 - %s'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = '이 작업을 수행하려면 %s 프로젝트의 멤버가 되어야 합니다'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = '입력이 완전하지 않습니다'; diff --git a/codepot/src/codepot/language/korean/wiki_lang.php b/codepot/src/codepot/language/korean/wiki_lang.php index b17bd6ca..036ec246 100644 --- a/codepot/src/codepot/language/korean/wiki_lang.php +++ b/codepot/src/codepot/language/korean/wiki_lang.php @@ -4,10 +4,8 @@ $lang['WIKI_NEW_ATTACHMENTS'] = '새로운 첨부파일'; $lang['WIKI_MORE_NEW_ATTACHMENTS'] = '첨부파일 추가'; $lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = '첨부파일이름에 콜론기호를 포함할 수 없습니다'; -$lang['WIKI_MSG_FAILED_TO_READ_ATTACHMENT'] = '위키 첨부파일을 읽을 수 없습니다 - %s'; $lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = '위키이름에 허용되지 않는 문자가 포함되어 있습니다'; $lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = '사용할 수 있는 위키 페이지가 없습니다'; $lang['WIKI_MSG_NO_SUCH_PAGE'] = '위키 페이지를 찾을수 없습니다 - %s'; -$lang['WIKI_MSG_NO_SUCH_ATTACHMENT'] = '위키 첨부파일을 찾을 수 없습니다 - %s'; $lang['WIKI_MSG_RESERVED_WIKI_NAME'] = '%s은(는) 사용할 수 없는 위키이름입니다'; ?> diff --git a/codepot/src/codepot/models/filemodel.php b/codepot/src/codepot/models/filemodel.php index 59071936..b27e2811 100644 --- a/codepot/src/codepot/models/filemodel.php +++ b/codepot/src/codepot/models/filemodel.php @@ -135,7 +135,7 @@ class FileModel extends Model } */ - function update ($userid, $projectid, $name, $file) + private function _update_file ($userid, $projectid, $name, $file) { $this->db->trans_start (); @@ -176,6 +176,15 @@ class FileModel extends Model return $this->db->trans_status(); } + function update ($userid, $projectid, $name, $file) + { + set_error_handler (array ($this, 'capture_error')); + $errmsg = ''; + $x = $this->_update_file ($userid, $projectid, $name, $file); + restore_error_handler (); + return $x; + } + private function _delete_file ($userid, $projectid, $name) { $this->db->trans_begin (); // manual transaction. not using trans_start(). diff --git a/codepot/src/codepot/models/loginmodel.php b/codepot/src/codepot/models/loginmodel.php index 90ce8a5e..71f1519b 100644 --- a/codepot/src/codepot/models/loginmodel.php +++ b/codepot/src/codepot/models/loginmodel.php @@ -43,7 +43,7 @@ class LoginModel extends Model { $settings = @unserialize ($settings); if ($settings === FALSE || $settings === NULL) - $settings = new stdObject(); + $settings = new stdClass(); // Sanity check on the session/cookie data // See Controller/User->settings() for required fields. diff --git a/codepot/src/codepot/views/file_show.php b/codepot/src/codepot/views/file_show.php index cd1f37af..8b180caf 100644 --- a/codepot/src/codepot/views/file_show.php +++ b/codepot/src/codepot/views/file_show.php @@ -26,6 +26,9 @@ converter->AsciiToHex ($file->name); $file_count = count ($file->file_list); + +$creole_base = site_url() . "/wiki/show/{$project->id}/"; +$creole_file_base = site_url() . "/wiki/attachment0/{$project->id}/"; ?> +id}/"; +// the issue page doesn't exist yet. so use wiki/attachment0 instead of +// issue/file/issueid. the local imange reference like {{xxx.png}} +// won't work. furthermore, the file hasn't been uploaded and isn't available. +$creole_file_base = site_url() . "/wiki/attachment0/{$project->id}/"; +?> +