added partial changes to support attachments in issue management
This commit is contained in:
		| @ -11,6 +11,7 @@ install-data-hook: | ||||
| 	$(INSTALL) -d "$(DESTDIR)@DEPOTDIR@" | ||||
| 	$(INSTALL) -d "$(DESTDIR)@DEPOTDIR@/svnrepo" | ||||
| 	$(INSTALL) -d "$(DESTDIR)@DEPOTDIR@/files" | ||||
| 	$(INSTALL) -d "$(DESTDIR)@DEPOTDIR@/issuefiles" | ||||
| 	$(INSTALL) -d "$(DESTDIR)@DEPOTDIR@/attachments" | ||||
| 	$(INSTALL) -d "$(DESTDIR)@DEPOTDIR@/usericons" | ||||
| 	$(INSTALL) -d "$(DESTDIR)@LOGDIR@" | ||||
| @ -19,6 +20,7 @@ install-data-hook: | ||||
| uninstall-hook: | ||||
| 	$(RMDIR) "$(DESTDIR)@DEPOTDIR@/usericons" | ||||
| 	$(RMDIR) "$(DESTDIR)@DEPOTDIR@/attachments" | ||||
| 	$(RMDIR) "$(DESTDIR)@DEPOTDIR@/issuefiles" | ||||
| 	$(RMDIR) "$(DESTDIR)@DEPOTDIR@/files" | ||||
| 	$(RMDIR) "$(DESTDIR)@DEPOTDIR@/svnrepo" | ||||
| 	$(RMDIR) "$(DESTDIR)@DEPOTDIR@" | ||||
|  | ||||
| @ -22,6 +22,8 @@ UPGRADING FROM 0.2.0 | ||||
|   mysql> ALTER TABLE file DROP COLUMN md5sum; | ||||
|   mysql> ALTER TABLE file DROP COLUMN encname; | ||||
|   mysql> ALTER TABLE project ADD COLUMN (codecharset VARCHAR(32)); | ||||
|   mysql> DROP TABLE issue_attachment; | ||||
|   mysql> create the issue_file_list table according to the definition found in codepot.mysql | ||||
|  | ||||
| INSTALLATION ON CENTOS | ||||
|  | ||||
|  | ||||
| @ -85,6 +85,7 @@ rm -rf $RPM_BUILD_ROOT | ||||
|  | ||||
| %dir %attr(-,apache,apache) /var/lib/codepot/svnrepo | ||||
| %dir %attr(-,apache,apache) /var/lib/codepot/files | ||||
| %dir %attr(-,apache,apache) /var/lib/codepot/issuefiles | ||||
| %dir %attr(-,apache,apache) /var/lib/codepot/attachments | ||||
| %dir %attr(-,apache,apache) /var/lib/codepot/usericons | ||||
| %dir %attr(-,apache,apache) /var/log/codepot | ||||
|  | ||||
| @ -186,6 +186,11 @@ svnrepo_dir = "@DEPOTDIR@/svnrepo" | ||||
| ;------------------------------------------------------------------------------ | ||||
| file_dir = "@DEPOTDIR@/files" | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ; directory to store issue attachments | ||||
| ;------------------------------------------------------------------------------ | ||||
| issue_file_dir = "@DEPOTDIR@/issuefiles" | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ; directory to store wiki attachments | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| @ -99,21 +99,24 @@ CREATE TABLE issue ( | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE | ||||
| ) charset=utf8 engine=InnoDB; | ||||
|  | ||||
| CREATE TABLE issue_attachment ( | ||||
| 	projectid  VARCHAR(32)   NOT NULL, | ||||
| 	issueid    BIGINT        NOT NULL, | ||||
| 	name       VARCHAR(255)  NOT NULL, | ||||
| 	encname    VARCHAR(255)  NOT NULL, | ||||
| CREATE TABLE issue_file_list ( | ||||
| 	projectid   VARCHAR(32)   NOT NULL, | ||||
| 	issueid     BIGINT        NOT NULL, | ||||
| 	filename    VARCHAR(255)  NOT NULL, | ||||
| 	encname     VARCHAR(255)  NOT NULL, | ||||
| 	md5sum      CHAR(32)      NOT NULL, | ||||
| 	description VARCHAR(255)  NOT NULL, | ||||
|  | ||||
| 	createdon  DATETIME      NOT NULL, | ||||
| 	createdby  VARCHAR(32)   NOT NULL, | ||||
| 	createdon   DATETIME      NOT NULL, | ||||
| 	createdby   VARCHAR(32)   NOT NULL, | ||||
|  | ||||
| 	UNIQUE KEY issue_attachment_id (projectid, issueid, name), | ||||
| 	UNIQUE KEY issue_file_list_id (projectid, issueid, filename), | ||||
| 	UNIQUE KEY (encname), | ||||
|  | ||||
| 	CONSTRAINT issue_attachment_projectid FOREIGN KEY (projectid) REFERENCES project(id) | ||||
| 	CONSTRAINT issue_file_list_projectid FOREIGN KEY (projectid) REFERENCES project(id) | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE, | ||||
|  | ||||
| 	CONSTRAINT issue_attachment_issueid FOREIGN KEY (projectid,issueid) REFERENCES issue(projectid,id) | ||||
| 	CONSTRAINT issue_file_list_issueid FOREIGN KEY (projectid,issueid) REFERENCES issue(projectid,id) | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE | ||||
| ) charset=utf8 engine=InnoDB; | ||||
|  | ||||
|  | ||||
| @ -517,4 +517,111 @@ class Issue extends Controller | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	function xhr_create ($projectid = '') | ||||
| 	{ | ||||
| 		$this->load->model ('ProjectModel', 'projects'); | ||||
| 		$this->load->model ('IssueModel', 'issues'); | ||||
| 		$this->load->library ('upload'); | ||||
|  | ||||
| 		$login = $this->login->getUser (); | ||||
| 		$revision_saved = -1; | ||||
|  | ||||
| 		if ($login['id'] == '') | ||||
| 		{ | ||||
| 			$status = 'error - anonymous user'; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			$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 | ||||
| 			{ | ||||
| 				$issue = new stdClass(); | ||||
| 				$issue->projectid = $projectid; | ||||
| 				$issue->summary = $this->input->post('issue_new_summary'); | ||||
| 				$issue->description = $this->input->post('issue_new_description'); | ||||
| 				$issue->type = $this->input->post('issue_new_type'); | ||||
| 				$issue->status = $this->issuehelper->STATUS_NEW; | ||||
| 				$issue->priority = $this->issuehelper->PRIORITY_OTHER; | ||||
| 				if ($this->projects->projectHasMember($project->id, $login['id'])) | ||||
| 				{ | ||||
| 					// let the current user be the issue owner if he/she is a | ||||
| 					// project memeber. | ||||
| 					$issue->owner = $login['id']; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					// if not, assign the issue to the first member. | ||||
| 					$issue->owner = (count($project->members) > 0)? $project->members[0]: ''; | ||||
| 				} | ||||
|  | ||||
| 				$post_new_file_count = $this->input->post('issue_new_file_count'); | ||||
|  | ||||
| 				if ($issue->type === FALSE || ($issue->type = trim($issue->type)) == '') | ||||
| 				{ | ||||
| 					$status = 'error - no type'; | ||||
| 				} | ||||
| 				else if ($issue->summary === FALSE || ($issue->summary = trim($issue->summary)) == '') | ||||
| 				{ | ||||
| 					$status = 'error - no name'; | ||||
| 				} | ||||
| 				else if ($issue->description === FALSE || ($issue->description = $issue->description) == '') | ||||
| 				{ | ||||
| 					$status = 'error - no description'; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					if ($post_new_file_count === FALSE || $post_new_file_count <= 0) $post_new_file_count = 0; | ||||
|  | ||||
| 					$status = ''; | ||||
| 					$attached_files = array (); | ||||
| 					for ($i = 0; $i < $post_new_file_count; $i++) | ||||
| 					{ | ||||
| 						$fid = "issue_new_file_{$i}"; | ||||
| 						if (array_key_exists($fid, $_FILES) && $_FILES[$fid]['name'] != '') | ||||
| 						{ | ||||
| 							$d = $this->input->post("issue_new_file_desc_{$i}"); | ||||
| 							if ($d === FALSE || ($d = trim($d)) == '') $d = ''; // description optional | ||||
|  | ||||
| 							if (strpos($_FILES[$fid]['name'], ':') !== FALSE || | ||||
| 							    strpos($_FILES[$fid]['name'], '/') !== FALSE) | ||||
| 							{ | ||||
| 								// prevents these letters for wiki creole  | ||||
| 								$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}"; | ||||
| 								break; | ||||
| 							} | ||||
|  | ||||
| 							array_push ($attached_files, array ('fid' => $fid, 'name' => $_FILES[$fid]['name'], 'desc' => $d)); | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
| 					if ($status == '') | ||||
| 					{ | ||||
| 						if ($this->issues->create_with_files ($login['id'], $issue, $attached_files, $this->upload) === FALSE) | ||||
| 						{ | ||||
| 							$status = 'error - ' . $this->issues->getErrorMessage(); | ||||
| 						} | ||||
| 						else | ||||
| 						{ | ||||
| 							$status = 'ok'; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		print $status; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -2,6 +2,18 @@ | ||||
|  | ||||
| class IssueModel extends Model | ||||
| { | ||||
| 	protected $errmsg = ''; | ||||
|  | ||||
| 	function capture_error ($errno, $errmsg) | ||||
| 	{ | ||||
| 		$this->errmsg = $errmsg; | ||||
| 	} | ||||
|  | ||||
| 	function getErrorMessage () | ||||
| 	{ | ||||
| 		return $this->errmsg; | ||||
| 	} | ||||
|  | ||||
| 	function IssueModel () | ||||
| 	{ | ||||
| 		parent::Model (); | ||||
| @ -184,7 +196,7 @@ class IssueModel extends Model | ||||
| 		$this->db->set ('projectid', $issue->projectid); | ||||
| 		$this->db->set ('userid',    $userid); | ||||
| 		$this->db->set ('message',   $newid); | ||||
|                 $this->db->insert ('log'); | ||||
| 		$this->db->insert ('log'); | ||||
|  | ||||
| 		$this->db->trans_complete (); | ||||
| 		if ($this->db->trans_status() === FALSE) return FALSE; | ||||
| @ -405,6 +417,143 @@ class IssueModel extends Model | ||||
| 		return $this->db->trans_status(); | ||||
| 	} | ||||
|  | ||||
| 	private function delete_all_files ($files) | ||||
| 	{ | ||||
| 		foreach ($files as $f) @unlink ($f); | ||||
| 	} | ||||
|  | ||||
| 	private function _create_issue ($userid, $issue, $attached_files, $uploader) | ||||
| 	{ | ||||
| 		$this->db->trans_begin (); // manual transaction. not using trans_start(). | ||||
|  | ||||
| 		$this->db->where ('projectid', $issue->projectid); | ||||
| 		$this->db->select ('MAX(id) as maxid'); | ||||
| 		$query = $this->db->get ('issue'); | ||||
| 		if ($this->db->trans_status() === FALSE)  | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$result = $query->result(); | ||||
| 		$maxid = (empty($result) || $result[0] == NULL)? 0: $result[0]->maxid; | ||||
|  | ||||
| 		$newid = $maxid + 1; | ||||
|  | ||||
| 		$this->db->set ('projectid', $issue->projectid); | ||||
| 		$this->db->set ('id', $newid); | ||||
| 		$this->db->set ('summary', $issue->summary); | ||||
| 		$this->db->set ('description', $issue->description); | ||||
| 		$this->db->set ('type', $issue->type); | ||||
| 		$this->db->set ('status', $issue->status); | ||||
| 		$this->db->set ('owner', $issue->owner); | ||||
| 		$this->db->set ('priority', $issue->priority); | ||||
| 		$this->db->set ('createdon', date('Y-m-d H:i:s')); | ||||
| 		$this->db->set ('updatedon', date('Y-m-d H:i:s')); | ||||
| 		$this->db->set ('createdby', $userid); | ||||
| 		$this->db->set ('updatedby', $userid); | ||||
| 		$this->db->insert ('issue'); | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$this->db->set ('projectid', $issue->projectid); | ||||
| 		$this->db->set ('id', $newid); | ||||
| 		$this->db->set ('sno', 1); | ||||
| 		$this->db->set ('type', $issue->type); | ||||
| 		$this->db->set ('status', $issue->status); | ||||
| 		$this->db->set ('owner', $issue->owner); | ||||
| 		$this->db->set ('comment', ''); | ||||
| 		$this->db->set ('priority', $issue->priority); | ||||
| 		$this->db->set ('updatedon', date('Y-m-d H:i:s')); | ||||
| 		$this->db->set ('updatedby', $userid); | ||||
| 		$this->db->insert ('issue_change'); | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$config['allowed_types'] = '*'; | ||||
| 		$config['upload_path'] = CODEPOT_ISSUE_FILE_DIR; | ||||
| 		$config['max_size'] = CODEPOT_MAX_UPLOAD_SIZE; | ||||
| 		$config['encrypt_name'] = TRUE; | ||||
| 		$config['overwrite'] = FALSE; | ||||
| 		$config['remove_spaces'] = FALSE; | ||||
| 		$uploader->initialize ($config); | ||||
|  | ||||
| 		$ok_files = array(); | ||||
| 		$file_count = count($attached_files); | ||||
| 		for ($i = 0; $i < $file_count; $i++) | ||||
| 		{ | ||||
| 			$f = $attached_files[$i]; | ||||
| 			if (!$uploader->do_upload($f['fid'])) | ||||
| 			{ | ||||
| 				$this->errmsg = "Failed to upload {$f['name']}"; | ||||
| 				$this->db->trans_rollback (); | ||||
| 				$this->delete_all_files ($ok_files); | ||||
| 				return FALSE; | ||||
| 			} | ||||
|  | ||||
| 			$ud = $uploader->data(); | ||||
| 			array_push ($ok_files, $ud['full_path']); | ||||
|  | ||||
| 			$md5sum = @md5_file ($ud['full_path']); | ||||
| 			if ($md5sum === FALSE) | ||||
| 			{ | ||||
| 				$this->db->trans_rollback (); | ||||
| 				$this->delete_all_files ($ok_files); | ||||
| 				return FALSE; | ||||
| 			} | ||||
|  | ||||
| 			$this->db->set ('projectid', $issue->projectid); | ||||
| 			$this->db->set ('issueid', $newid); | ||||
| 			$this->db->set ('filename', $f['name']); | ||||
| 			$this->db->set ('encname', $ud['file_name']); | ||||
| 			$this->db->set ('description', $f['desc']); | ||||
| 			$this->db->set ('md5sum', $md5sum); | ||||
| 			$this->db->insert ('issue_file_list'); | ||||
| 			if ($this->db->trans_status() === FALSE) | ||||
| 			{ | ||||
| 				$this->errmsg = $this->db->_error_message();  | ||||
| 				$this->db->trans_rollback (); | ||||
| 				$this->delete_all_files ($ok_files); | ||||
| 				return FALSE; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		$this->db->set ('createdon', date('Y-m-d H:i:s')); | ||||
| 		$this->db->set ('type',      'issue'); | ||||
| 		$this->db->set ('action',    'create'); | ||||
| 		$this->db->set ('projectid', $issue->projectid); | ||||
| 		$this->db->set ('userid',    $userid); | ||||
| 		$this->db->set ('message',   $newid); | ||||
| 		$this->db->insert ('log'); | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			$this->delete_all_files ($ok_files); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$this->db->trans_commit (); | ||||
| 		return $newid; | ||||
| 	} | ||||
|  | ||||
| 	function create_with_files ($userid, $issue, $attached_files, $uploader) | ||||
| 	{ | ||||
| 		set_error_handler (array ($this, 'capture_error')); | ||||
| 		$errmsg = ''; | ||||
| 		$x = $this->_create_issue ($userid, $issue, $attached_files, $uploader); | ||||
| 		restore_error_handler (); | ||||
| 		return $x; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
|  | ||||
| @ -10,12 +10,37 @@ | ||||
| <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/issue.css')?>" /> | ||||
| <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/font-awesome.min.css')?>" /> | ||||
|  | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/creole.js')?>"></script> | ||||
|  | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/prettify/prettify.js')?>"></script> | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-css.js')?>"></script> | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-lisp.js')?>"></script> | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-lua.js')?>"></script> | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-sql.js')?>"></script> | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/prettify/lang-vb.js')?>"></script> | ||||
|  | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/jquery.min.js')?>"></script> | ||||
| <script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script> | ||||
| <link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" /> | ||||
|  | ||||
| <script type="text/javascript"> | ||||
| /* <![CDATA[ */ | ||||
| function show_alert (outputMsg, titleMsg)  | ||||
| { | ||||
| 	$('#issue_home_mainarea_alert').html(outputMsg).dialog({ | ||||
| 		title: titleMsg, | ||||
| 		resizable: true, | ||||
| 		modal: true, | ||||
| 		width: 'auto', | ||||
| 		height: 'auto', | ||||
| 		buttons: { | ||||
| 			"OK": function () { | ||||
| 				$(this).dialog("close"); | ||||
| 			} | ||||
| 		} | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| function AsciiToHex (x) { | ||||
| 	var r=""; | ||||
| 	for(i=0; i<x.length; i++) | ||||
| @ -27,7 +52,177 @@ function AsciiToHex (x) { | ||||
| 	return r; | ||||
| } | ||||
|  | ||||
|  | ||||
| function render_wiki(input_text) | ||||
| { | ||||
| 	creole_render_wiki_with_input_text ( | ||||
| 		input_text, | ||||
| 		"issue_home_mainarea_new_description_preview",  | ||||
| 		"<?php print site_url()?>/wiki/show/<?php print $project->id?>/", | ||||
| 		"<?php print site_url()?>/wiki/attachment0/<?php print $project->id?>/" | ||||
| 	); | ||||
|  | ||||
| 	prettyPrint (); | ||||
| } | ||||
|  | ||||
| var import_in_progress = false; | ||||
| var populated_file_obj = []; | ||||
| var populated_file_max = 0; | ||||
|  | ||||
| function populate_selected_files () | ||||
| { | ||||
| 	var issue_file_desc = {}; | ||||
| 	for (var n = 0; n < populated_file_max; n++) | ||||
| 	{ | ||||
| 		var f = populated_file_obj[n]; | ||||
| 		if (f != null) | ||||
| 		{ | ||||
| 			var d = $('#issue_home_mainarea_new_file_desc_' + n); | ||||
| 			if (d != null) issue_file_desc[f.name] = d.val(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$('#issue_home_mainarea_new_file_table').empty(); | ||||
| 	populated_file_obj = []; | ||||
|  | ||||
| 	var f = $('#issue_home_mainarea_new_files').get(0); | ||||
| 	var f_no = 0; | ||||
| 	for (var n = 0; n < f.files.length; n++) | ||||
| 	{ | ||||
| 		if (f.files[n] != null)  | ||||
| 		{ | ||||
| 			var desc = issue_file_desc[f.files[n].name]; | ||||
| 			if (desc == null) desc = ''; | ||||
|  | ||||
| 			$('#issue_home_mainarea_new_file_table').append ( | ||||
| 				codepot_sprintf ( | ||||
| 					'<tr id="issue_home_mainarea_new_file_row_%d"><td><a href="#" id="issue_home_mainarea_new_file_cancel_%d" onClick="cancel_out_new_file(%d); return false;"><i class="fa fa-trash"></i></a></td><td>%s</td><td><input type="text" id="issue_home_mainarea_new_file_desc_%d" size="40" value="%s" /></td></tr>',  | ||||
| 					f_no, f_no, f_no, codepot_htmlspecialchars(f.files[n].name), f_no, codepot_addslashes(desc) | ||||
| 				) | ||||
| 			); | ||||
|  | ||||
| 			populated_file_obj[f_no] = f.files[n]; | ||||
| 			f_no++; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	populated_file_max = f_no; | ||||
| } | ||||
|  | ||||
| function cancel_out_new_file (no) | ||||
| { | ||||
| 	$('#issue_home_mainarea_new_file_row_' + no).remove (); | ||||
| 	populated_file_obj[no] = null; | ||||
| } | ||||
|  | ||||
| $(function () {  | ||||
| <?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| 	$('#issue_home_mainarea_new_files').change (function () { | ||||
| 		populate_selected_files (); | ||||
| 	}); | ||||
|  | ||||
| 	$("#issue_home_mainarea_new_description_tabs").tabs (); | ||||
| 	$("#issue_home_mainarea_new_description_tabs").bind ('tabsshow', function (event, ui) { | ||||
| 		if (ui.index == 1) render_wiki ($("#issue_home_mainarea_new_description").val()); | ||||
| 	}); | ||||
|  | ||||
| 	$('#issue_home_mainarea_new_form').dialog ( | ||||
| 		{ | ||||
| 			title: '<?php print $this->lang->line('New');?>', | ||||
| 			resizable: true, | ||||
| 			autoOpen: false, | ||||
| 			width: 'auto', | ||||
| 			height: 'auto', | ||||
| 			modal: true, | ||||
| 			buttons: { | ||||
|  | ||||
| 				'<?php print $this->lang->line('OK')?>': function () { | ||||
| 					if (import_in_progress) return; | ||||
|  | ||||
| 					if (!!window.FormData) | ||||
| 					{ | ||||
| 						// FormData is supported | ||||
| 						import_in_progress = true; | ||||
|  | ||||
| 						var form_data = new FormData(); | ||||
|  | ||||
| 						var f_no = 0; | ||||
| 						for (var i = 0; i <= populated_file_max; i++) | ||||
| 						{ | ||||
|  | ||||
| 							var f = populated_file_obj[i]; | ||||
| 							if (f != null) | ||||
| 							{ | ||||
| 								form_data.append ('issue_new_file_' + f_no, f); | ||||
|  | ||||
| 								var d = $('#issue_home_mainarea_new_file_desc_' + i); | ||||
| 								if (d != null) form_data.append('issue_new_file_desc_' + f_no, d.val()); | ||||
|  | ||||
| 								f_no++; | ||||
| 							} | ||||
| 						} | ||||
|  | ||||
| 						form_data.append ('issue_new_file_count', f_no); | ||||
| 						form_data.append ('issue_new_type', $('#issue_home_mainarea_new_type').val()); | ||||
| 						form_data.append ('issue_new_summary', $('#issue_home_mainarea_new_summary').val()); | ||||
| 						form_data.append ('issue_new_description', $('#issue_home_mainarea_new_description').val()); | ||||
|  | ||||
| 						$('#issue_home_mainarea_new_form').dialog('disable'); | ||||
| 						$.ajax({ | ||||
| 							url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/issue/xhr_create/{$project->id}"; ?>'), | ||||
| 							type: 'POST', | ||||
| 							data: form_data, | ||||
| 							mimeType: 'multipart/form-data', | ||||
| 							contentType: false, | ||||
| 							processData: false, | ||||
| 							cache: false, | ||||
|  | ||||
| 							success: function (data, textStatus, jqXHR) {  | ||||
| 								import_in_progress = false; | ||||
| 								$('#issue_home_mainarea_new_form').dialog('enable'); | ||||
| 								$('#issue_home_mainarea_new_form').dialog('close'); | ||||
| 								if (data == 'ok')  | ||||
| 								{ | ||||
| 									// refresh the page to the head revision | ||||
| 									$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/issue/home/{$project->id}"; ?>')); | ||||
| 								} | ||||
| 								else | ||||
| 								{ | ||||
| 									show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>"); | ||||
| 								} | ||||
| 							}, | ||||
|  | ||||
| 							error: function (jqXHR, textStatus, errorThrown) {  | ||||
| 								import_in_progress = false; | ||||
| 								$('#issue_home_mainarea_new_form').dialog('enable'); | ||||
| 								$('#issue_home_mainarea_new_form').dialog('close'); | ||||
| 								var errmsg = ''; | ||||
| 								if (errmsg == '' && errorThrown != null) errmsg = errorThrown; | ||||
| 								if (errmsg == '' && textStatus != null) errmsg = textStatus; | ||||
| 								if (errmsg == '') errmsg = 'Unknown error'; | ||||
| 								show_alert ('Failed - ' + errmsg, "<?php print $this->lang->line('Error')?>"); | ||||
| 							} | ||||
| 						}); | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						show_alert ('<pre>NOT SUPPORTED</pre>', "<?php print $this->lang->line('Error')?>"); | ||||
| 					} | ||||
| 				}, | ||||
| 				'<?php print $this->lang->line('Cancel')?>': function () { | ||||
| 					if (import_in_progress) return; | ||||
| 					$('#issue_home_mainarea_new_form').dialog('close'); | ||||
| 				} | ||||
| 			}, | ||||
|  | ||||
| 			beforeClose: function() {  | ||||
| 				// if importing is in progress, prevent dialog closing | ||||
| 				return !import_in_progress; | ||||
| 			} | ||||
| 		} | ||||
| 	); | ||||
| <?php endif; ?> | ||||
|  | ||||
| 	$("#issue_home_mainarea_search_form").dialog ({ | ||||
| 		title: '<?php print $this->lang->line('Search')?>', | ||||
| 		autoOpen: false, | ||||
| @ -50,6 +245,15 @@ $(function () { | ||||
| 	});  | ||||
|  | ||||
|  | ||||
| <?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| 	$("#issue_home_mainarea_new_button").button().click ( | ||||
| 		function () {  | ||||
| 			$('#issue_home_mainarea_new_form').dialog('open');  | ||||
| 			return false; // prevent the default behavior | ||||
| 		} | ||||
| 	); | ||||
| <?php endif; ?> | ||||
|  | ||||
| 	$("#issue_home_mainarea_search_button").button().click ( | ||||
| 		function () {  | ||||
| 			$('#issue_home_mainarea_search_form').dialog('open');  | ||||
| @ -99,62 +303,12 @@ $this->load->view ( | ||||
|  | ||||
| <div class="infostrip"> | ||||
| <?php printf ($this->lang->line('ISSUE_MSG_TOTAL_NUM_ISSUES'), $total_num_issues); ?> |  | ||||
| <?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| <a id="issue_home_mainarea_new_button" href='#'><?php print $this->lang->line('New')?></a> | ||||
| <?php endif; ?> | ||||
| <a id="issue_home_mainarea_search_button" href='#'><?php print $this->lang->line('Search')?></a> | ||||
| </div> | ||||
|  | ||||
| <div id="issue_home_mainarea_search_form"> | ||||
| 	<?php | ||||
| 		$issue_type_array[''] = $this->lang->line('All'); | ||||
| 		$issue_status_array[''] = $this->lang->line('All'); | ||||
| 		$issue_priority_array[''] = $this->lang->line('All'); | ||||
| 	?> | ||||
| 	<form id="issue_search_form" action=""> | ||||
| 		<div> | ||||
| 			<?php print form_label ($this->lang->line('Type'), 'issue_search_type') | ||||
| 			?> | ||||
| 			<?php print form_dropdown('type', | ||||
| 				$issue_type_array, | ||||
| 				set_value('type', $search->type),  | ||||
| 				'id="issue_search_type"') | ||||
| 			?> | ||||
| 	 | ||||
| 			<?php print form_label ($this->lang->line('Status'), 'issue_search_status') | ||||
| 			?> | ||||
| 			<?php print form_dropdown('status', | ||||
| 				$issue_status_array, | ||||
| 				set_value('status', $search->status), 'id="issue_search_status"') | ||||
| 			?> | ||||
|  | ||||
| 			<?php print form_label ($this->lang->line('Priority'), 'issue_search_priority') | ||||
| 			?> | ||||
| 			<?php print form_dropdown('priority', | ||||
| 				$issue_priority_array, | ||||
| 				set_value('priority', $search->priority), | ||||
| 				'id="issue_search_priority"') | ||||
| 			?> | ||||
| 		</div> | ||||
|  | ||||
|  | ||||
| 		<div> | ||||
| 			<?php print form_label ($this->lang->line('Owner'), 'issue_search_owner') | ||||
| 			?> | ||||
| 			<?php print form_input('owner', | ||||
| 				set_value('owner', $search->owner), | ||||
| 				'id="issue_search_owner"') | ||||
| 			?> | ||||
| 		</div> | ||||
|  | ||||
| 		<div> | ||||
| 			<?php print form_label ($this->lang->line('Summary'), 'issue_search_summary') | ||||
| 			?> | ||||
| 			<?php print form_input('summary', | ||||
| 				set_value('summary', $search->summary), | ||||
| 				'id="issue_search_summary" size="50"') | ||||
| 			?> | ||||
| 		</div> | ||||
|  | ||||
| 	</form> | ||||
| </div> | ||||
|  | ||||
|  | ||||
| <div class="result" id="issue_home_mainarea_result"> | ||||
| @ -223,6 +377,98 @@ else | ||||
| ?> | ||||
| </div> <!-- issue_home_mainarea_result --> | ||||
|  | ||||
| <?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| <div id='issue_home_mainarea_new_form'> | ||||
| 	<div style='line-height: 2em;'> | ||||
| 		<?php 		 | ||||
| 		print form_dropdown ( | ||||
| 			'issue_home_new_type',  | ||||
| 			$issue_type_array, | ||||
| 			set_value('issue_home_new_type', ''), | ||||
| 			'id="issue_home_mainarea_new_type"' | ||||
| 		); | ||||
| 		?> | ||||
|  | ||||
| 		<input type='text' id='issue_home_mainarea_new_summary' name='issue_home_new_summary' size='50' placeholder='<?php print $this->lang->line('Summary'); ?>'/> | ||||
| 	</div> | ||||
|  | ||||
| 	<div id='issue_home_mainarea_new_description_tabs' style='width:100%;'> | ||||
| 		<ul> | ||||
| 			<li><a href='#issue_home_mainarea_new_description_input'><?php print $this->lang->line('Description'); ?></a></li> | ||||
| 			<li><a href='#issue_home_mainarea_new_description_preview'><?php print $this->lang->line('Preview'); ?></a></li> | ||||
| 		</ul> | ||||
|  | ||||
| 		<div id='issue_home_mainarea_new_description_input'> | ||||
| 			<textarea type='textarea' id='issue_home_mainarea_new_description' name='issue_home_new_description' rows=24 cols=100 style='width:100%;'></textarea> | ||||
|  | ||||
| 			<div style='margin-top: 0.1em;'> | ||||
| 			<?php print $this->lang->line('Attachments'); ?> | ||||
| 			<input type='file' id='issue_home_mainarea_new_files' name='issue_home_new_files' multiple='' autocomplete='off' style='color: transparent;' /> | ||||
| 			<table id='issue_home_mainarea_new_file_table'></table> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 		<div id='issue_home_mainarea_new_description_preview' class='form_input_preview'> | ||||
| 		</div> | ||||
| 	</div> | ||||
| </div> | ||||
| <?php endif; ?> | ||||
|  | ||||
| <div id="issue_home_mainarea_search_form"> | ||||
| 	<?php | ||||
| 		$issue_type_array[''] = $this->lang->line('All'); | ||||
| 		$issue_status_array[''] = $this->lang->line('All'); | ||||
| 		$issue_priority_array[''] = $this->lang->line('All'); | ||||
| 	?> | ||||
| 	<form id="issue_search_form" action=""> | ||||
| 		<div> | ||||
| 			<?php print form_label ($this->lang->line('Type'), 'issue_search_type') | ||||
| 			?> | ||||
| 			<?php print form_dropdown('type', | ||||
| 				$issue_type_array, | ||||
| 				set_value('type', $search->type),  | ||||
| 				'id="issue_search_type"') | ||||
| 			?> | ||||
| 	 | ||||
| 			<?php print form_label ($this->lang->line('Status'), 'issue_search_status') | ||||
| 			?> | ||||
| 			<?php print form_dropdown('status', | ||||
| 				$issue_status_array, | ||||
| 				set_value('status', $search->status), 'id="issue_search_status"') | ||||
| 			?> | ||||
|  | ||||
| 			<?php print form_label ($this->lang->line('Priority'), 'issue_search_priority') | ||||
| 			?> | ||||
| 			<?php print form_dropdown('priority', | ||||
| 				$issue_priority_array, | ||||
| 				set_value('priority', $search->priority), | ||||
| 				'id="issue_search_priority"') | ||||
| 			?> | ||||
| 		</div> | ||||
|  | ||||
|  | ||||
| 		<div> | ||||
| 			<?php print form_label ($this->lang->line('Owner'), 'issue_search_owner') | ||||
| 			?> | ||||
| 			<?php print form_input('owner', | ||||
| 				set_value('owner', $search->owner), | ||||
| 				'id="issue_search_owner"') | ||||
| 			?> | ||||
| 		</div> | ||||
|  | ||||
| 		<div> | ||||
| 			<?php print form_label ($this->lang->line('Summary'), 'issue_search_summary') | ||||
| 			?> | ||||
| 			<?php print form_input('summary', | ||||
| 				set_value('summary', $search->summary), | ||||
| 				'id="issue_search_summary" size="50"') | ||||
| 			?> | ||||
| 		</div> | ||||
|  | ||||
| 	</form> | ||||
| </div> | ||||
|  | ||||
| <div id='issue_home_mainarea_alert'></div> | ||||
|  | ||||
| </div> <!-- issue_home_mainarea --> | ||||
|  | ||||
| <div class='footer-pusher'></div> <!-- for sticky footer --> | ||||
|  | ||||
| @ -72,6 +72,7 @@ function load_ini ($file) | ||||
|  | ||||
| 		array ('svnrepo_dir',                  'string',      CODEPOT_DEPOT_DIR.'/svnrepo'), | ||||
| 		array ('file_dir',                     'string',      CODEPOT_DEPOT_DIR.'/files'), | ||||
| 		array ('issue_file_dir',               'string',      CODEPOT_DEPOT_DIR.'/issuefiles'), | ||||
| 		array ('attachment_dir',               'string',      CODEPOT_DEPOT_DIR.'/attachments'), | ||||
| 		array ('usericon_dir',                 'string',      CODEPOT_DEPOT_DIR.'/usericons'), | ||||
|  | ||||
|  | ||||
| @ -12,6 +12,18 @@ body { | ||||
| 	height: 100%; /* for sticky footer */ | ||||
| } | ||||
|  | ||||
| textarea { | ||||
| 	font-family: consolas, monaco, "Andale Mono", monospace; | ||||
|  | ||||
| 	tab-size: 5; | ||||
| 	-moz-tab-size: 5; | ||||
| 	-o-tab-size: 5; | ||||
|  | ||||
| 	-moz-box-sizing: border-box; | ||||
| 	-webkit-box-sizing: border-box; | ||||
| 	box-sizing: border-box; | ||||
| } | ||||
|  | ||||
| .content { | ||||
| 	font-size: 0.9em; | ||||
| 	font-family: /*Ubuntu,*/ "Trebuchet MS", Tahoma, Verdana, sans-serif; | ||||
| @ -80,14 +92,6 @@ body { | ||||
| 	white-space: pre-wrap !important; | ||||
| } | ||||
|  | ||||
| .content textarea { | ||||
| 	font-family: consolas, monaco, "Andale Mono", monospace; | ||||
|  | ||||
| 	tab-size: 5; | ||||
| 	-moz-tab-size: 5; | ||||
| 	-o-tab-size: 5; | ||||
| } | ||||
|  | ||||
| .content .collapsible-box { | ||||
| 	margin: 0; | ||||
| 	padding: 0; | ||||
| @ -97,7 +101,7 @@ body { | ||||
| 	background: #E5ECF9 none repeat scroll 0 0; | ||||
| 	border: #D4DBE8 1px solid; | ||||
| 	color: #1C94C4; | ||||
|         font-size: 0.9em; | ||||
| 	font-size: 0.9em; | ||||
| } | ||||
|  | ||||
| .content .collapsible-box-list { | ||||
|  | ||||
| @ -59,3 +59,34 @@ | ||||
| } | ||||
|  | ||||
|  | ||||
| /*----------------------------------------------- | ||||
|  * file home view - new file dialog | ||||
|  *-----------------------------------------------*/ | ||||
| #file_home_mainarea_new_description_tabs { | ||||
| 	border: none !important; | ||||
| } | ||||
|  | ||||
| #file_home_mainarea_new_description_tabs .ui-tabs-panel { | ||||
| 	padding: 0.2em 0em 0em 0em !important; | ||||
| } | ||||
|  | ||||
| #file_home_mainarea_new_description_tabs .ui-widget-header { | ||||
| 	border: none !important; | ||||
| 	background: none !important; | ||||
| 	padding: 0em !important; | ||||
| } | ||||
|  | ||||
| #file_home_mainarea_new_description_tabs .ui-tabs-nav { | ||||
| 	padding: 0em !important; | ||||
| } | ||||
|  | ||||
| /* #file_home_mainarea_new_description_tabs .ui-tabs-nav li { */ | ||||
| .ui-tabs .ui-tabs-nav li.ui-state-default { | ||||
| 	border-bottom: 1px solid #cccccc !important; | ||||
| } | ||||
|  | ||||
| .ui-tabs .ui-tabs-nav li.ui-state-active { | ||||
| 	border-bottom: 1px solid #fbd850 !important; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -204,3 +204,34 @@ | ||||
| #issue_edit_mainarea_buttons { | ||||
| 	padding-top: 0.5em; | ||||
| } | ||||
|  | ||||
|  | ||||
| /*----------------------------------------------- | ||||
|  * issue home view - new issue dialog | ||||
|  *-----------------------------------------------*/ | ||||
| #issue_home_mainarea_new_description_tabs { | ||||
| 	border: none !important; | ||||
| } | ||||
|  | ||||
| #issue_home_mainarea_new_description_tabs .ui-tabs-panel { | ||||
| 	padding: 0.2em 0em 0em 0em !important; | ||||
| } | ||||
|  | ||||
| #issue_home_mainarea_new_description_tabs .ui-widget-header { | ||||
| 	border: none !important; | ||||
| 	background: none !important; | ||||
| 	padding: 0em !important; | ||||
| } | ||||
|  | ||||
| #issue_home_mainarea_new_description_tabs .ui-tabs-nav { | ||||
| 	padding: 0em !important; | ||||
| } | ||||
|  | ||||
| /* #issue_home_mainarea_new_description_tabs .ui-tabs-nav li { */ | ||||
| .ui-tabs .ui-tabs-nav li.ui-state-default { | ||||
| 	border-bottom: 1px solid #cccccc !important; | ||||
| } | ||||
|  | ||||
| .ui-tabs .ui-tabs-nav li.ui-state-active { | ||||
| 	border-bottom: 1px solid #fbd850 !important; | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user