function get_one_comment_array($v = array(), $all_parties = array()) { global $TPL; $current_user =& singleton("current_user"); $new = $v; $token = new token(); if ($token->select_token_by_entity_and_action("comment", $new["commentID"], "add_comment_from_email")) { if ($token->get_value("tokenHash")) { $new["hash"] = $token->get_value("tokenHash"); $new["hashKey"] = "{Key:" . $new["hash"] . "}"; $new["hashHTML"] = " <em class=\"faint\">" . $new["hashKey"] . "</em>"; } $ip = interestedParty::get_interested_parties("comment", $new["commentID"]); foreach ((array) $ip as $email => $info) { $all_parties += $ip; if ($info["selected"]) { $sel[] = $email; } } foreach ($all_parties as $email => $i) { in_array($email, (array) $sel) and $recipient_selected[] = $i["identifier"]; } if (interestedParty::is_external("comment", $new["commentID"])) { $new["external"] = " loud"; $label = "<em class='faint warn'>[ External Conversation ]</em>"; } else { $label = "<em class='faint'>[ Internal Conversation ]</em>"; } foreach ((array) $all_parties as $email => $info) { $recipient_ops[$info["identifier"]] = $info["name"] . " <" . $email . ">"; } $new["recipient_editor"] = "<span class='nobr' style='width:100%;display:inline;' class='recipient_editor'>"; $new["recipient_editor"] .= "<span class='noprint hidden' id='recipient_dropdown_" . $new["commentID"] . "'>\n <form action='" . $TPL["url_alloc_updateRecipients"] . "' method='post'>\n <select name='comment_recipients[]' multiple='true' data-callback='save_recipients'>\n " . page::select_options($recipient_ops, $recipient_selected) . "\n </select>\n <input type='hidden' name='commentID' value='" . $new["commentID"] . "'>\n <input type='submit' value='Go' style='display:none'>\n </form>\n </span>"; $new["recipient_editor"] .= "<a class='magic recipient_editor_link' id='r_e_" . $new["commentID"] . "' style='text-decoration:none' href='#x'>" . $label . "</a>"; $new["recipient_editor"] .= "</span>"; $new["reply"] = '<a href="" class="noprint commentreply">reply</a>'; } if ($v["timeSheetID"]) { $timeSheet = new timeSheet(); $timeSheet->set_id($v["timeSheetID"]); $v["ts_label"] = " (Time Sheet #" . $timeSheet->get_id() . ")"; } $new["attribution"] = comment::get_comment_attribution($v); $new["commentCreatedUserEmail"] = comment::get_comment_author_email($v); $s = commentTemplate::populate_string(config::get_config_item("emailSubject_taskComment"), $entity, $id); $new["commentEmailSubject"] = $s . " " . $new["hashKey"]; if (!$_GET["commentID"] || $_GET["commentID"] != $v["commentID"]) { if ($options["showEditButtons"] && $new["comment_buttons"]) { $new["form"] = '<form action="' . $TPL["url_alloc_comment"] . '" method="post">'; $new["form"] .= '<input type="hidden" name="entity" value="' . $v["commentType"] . '">'; $new["form"] .= '<input type="hidden" name="entityID" value="' . $v["commentLinkID"] . '">'; $new["form"] .= '<input type="hidden" name="commentID" value="' . $v["commentID"] . '">'; $new["form"] .= '<input type="hidden" name="comment_id" value="' . $v["commentID"] . '">'; $new["form"] .= $new["comment_buttons"]; $new["form"] .= '<input type="hidden" name="sessID" value="' . $TPL["sessID"] . '">'; $new["form"] .= '</form>'; } $v["commentMimeParts"] and $files = unserialize($v["commentMimeParts"]); if (is_array($files)) { foreach ($files as $file) { $new["files"] .= '<div align="center" style="float:left; display:inline; margin-right:14px;">'; $new["files"] .= "<a href=\"" . $TPL["url_alloc_getMimePart"] . "part=" . $file["part"] . "&entity=comment&id=" . $v["commentID"] . "\">"; $new["files"] .= get_file_type_image($file["name"]) . "<br>" . page::htmlentities($file["name"]); $new["files"] .= " (" . get_size_label($file["size"]) . ")</a>"; $new["files"] .= '</div>'; } } $v["commentEmailRecipients"] and $new["emailed"] = 'Emailed to ' . page::htmlentities($v["commentEmailRecipients"]); } return (array) $new; }
function get_attachments($entity, $id, $ops = array()) { global $TPL; $rows = array(); $dir = ATTACHMENTS_DIR . $entity . DIRECTORY_SEPARATOR . $id; if (isset($id)) { #if (!is_dir($dir)) { #mkdir($dir, 0777); #} if (is_dir($dir)) { $handle = opendir($dir); // TODO add icons to files attachaments in general while (false !== ($file = readdir($handle))) { clearstatcache(); if ($file != "." && $file != "..") { $image = get_file_type_image($dir . DIRECTORY_SEPARATOR . $file); $row["size"] = get_filesize_label($dir . DIRECTORY_SEPARATOR . $file); $row["path"] = $dir . DIRECTORY_SEPARATOR . $file; $row["file"] = "<a href=\"" . $TPL["url_alloc_getDoc"] . "id=" . $id . "&entity=" . $entity . "&file=" . urlencode($file) . "\">" . $image . $ops["sep"] . page::htmlentities($file) . "</a>"; $row["text"] = page::htmlentities($file); #$row["delete"] = "<a href=\"".$TPL["url_alloc_delDoc"]."id=".$id."&entity=".$entity."&file=".urlencode($file)."\">Delete</a>"; $row["delete"] = "<form action=\"" . $TPL["url_alloc_delDoc"] . "\" method=\"post\">\n <input type=\"hidden\" name=\"id\" value=\"" . $id . "\">\n <input type=\"hidden\" name=\"file\" value=\"" . $file . "\">\n <input type=\"hidden\" name=\"entity\" value=\"" . $entity . "\">\n <input type=\"hidden\" name=\"sbs_link\" value=\"attachments\">\n <input type=\"hidden\" name=\"sessID\" value=\"{$sessID}\">" . '<button type="submit" name="delete_file_attachment" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>' . "</form>"; $row["mtime"] = date("Y-m-d H:i:s", filemtime($dir . DIRECTORY_SEPARATOR . $file)); $row["restore_name"] = $file; $rows[] = $row; } } closedir($handle); } is_array($rows) && usort($rows, "sort_by_mtime"); } return $rows; }