/** * Iterate through the patches and comments to get the reviewers. */ function getReviewers() { $rev = new ArrayObject(); foreach ($this->get_patches_list() as $p) { foreach ($p->get_comments_list() as $c) { $rev[] = $c->get_submitter(); } } return Pluf_Model_RemoveDuplicates($rev); }
/** * Get models affected by delete. * * @return array Models deleted if deleting current model. */ function getDeleteSideEffect() { $affected = array(); foreach ($this->_m['list'] as $method => $details) { if (is_array($details)) { // foreignkey $related = $this->{$method}(); $affected = array_merge($affected, (array) $related); foreach ($related as $rel) { if ($details[0] == $this->_a['model'] and $rel->id == $this->_data['id']) { continue; // $rel == $this } $affected = array_merge($affected, (array) $rel->getDeleteSideEffect()); } } } return Pluf_Model_RemoveDuplicates($affected); }
public function view($request, $match) { $prj = $request->project; $review = Pluf_Shortcuts_GetObjectOr404('IDF_Review', $match[2]); $prj->inOr404($review); $url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($prj->shortname, $review->id)); $title = Pluf_Template::markSafe(sprintf(__('Review <a href="%s">%d</a>: %s'), $url, $review->id, $review->summary)); $patches = $review->get_patches_list(); $patch = $patches[0]; $diff = new IDF_Diff(file_get_contents(Pluf::f('upload_issue_path') . '/' . $patch->patch)); $diff->parse(); // The form to submit comments is based on the files in the // diff if ($request->method == 'POST' and !$request->user->isAnonymous()) { $form = new IDF_Form_ReviewFileComment($request->POST, array('files' => $diff->files, 'user' => $request->user, 'patch' => $patch, 'project' => $prj)); if ($form->isValid()) { $review_comment = $form->save(); $review = $patch->get_review(); $urlr = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($prj->shortname, $review->id)); $request->user->setMessage(sprintf(__('Your <a href="%s">code review %d</a> has been published.'), $urlr, $review->id)); $url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::index', array($prj->shortname)); $review_comment->notify($request->conf); return new Pluf_HTTP_Response_Redirect($url); } } else { $form = new IDF_Form_ReviewFileComment(null, array('files' => $diff->files, 'user' => $request->user, 'project' => $prj, 'patch' => $patch)); } $scm = IDF_Scm::get($request->project); $files = array(); $reviewers = array(); foreach ($diff->files as $filename => $def) { $fileinfo = $scm->getPathInfo($filename, $patch->get_commit()->scm_id); $sql = new Pluf_SQL('cfile=%s', array($filename)); $cts = $patch->getFileComments(array('filter' => $sql->gen(), 'order' => 'creation_dtime ASC')); foreach ($cts as $ct) { $reviewers[] = $ct->get_comment()->get_submitter(); } if (count($def['chunks'])) { $orig_file = $fileinfo ? $scm->getFile($fileinfo) : ''; $files[$filename] = array($diff->fileCompare($orig_file, $def, $filename), $form->f->{md5($filename)}, $cts); } else { $files[$filename] = array('', $form->f->{md5($filename)}, $cts); } } $reviewers = Pluf_Model_RemoveDuplicates($reviewers); return Pluf_Shortcuts_RenderToResponse('idf/review/view.html', array_merge(array('page_title' => $title, 'review' => $review, 'files' => $files, 'diff' => $diff, 'patch' => $patch, 'comments' => $patch->get_comments_list(array('sort' => 'id ASC')), 'form' => $form, 'reviewers' => $reviewers), IDF_Views_Issue::autoCompleteArrays($prj)), $request); }