/** * Add comment to specified item * * @param string $type can be one of: ["ca_objects", "ca_entities", "ca_places", "ca_occurrences", "ca_collections", "ca_list_items", "ca_object_representations", "ca_storage_locations", "ca_movements", "ca_loans", "ca_tours", "ca_tour_stops"] * @param int $item_id primary key * @param array $comment_info_array * @return boolean * @throws SoapFault */ public function addComment($type, $item_id, $comment_info_array) { if (!($t_subject_instance = $this->getTableInstance($type, $item_id))) { throw new SoapFault("Server", "Invalid type or item_id"); } $t_comment = new ca_item_comments(); $t_comment->setMode(ACCESS_WRITE); $t_comment->set($comment_info_array); $t_comment->set('table_num', $t_subject_instance->tableNum()); $t_comment->set('row_id', $t_subject_instance->getPrimaryKey()); $t_comment->set('user_id', $this->getUserID()); $vn_id = $t_comment->insert(); if ($t_comment->numErrors() == 0) { return $vn_id; } else { throw new SoapFault("Server", "There were errors while adding the comment: " . join(";", $t_comment->getErrors())); } }
/** * Permanently deletes the comment specified by $pn_comment_id. Will only delete comments attached to the * currently loaded row. If you attempt to delete a comment_id not attached to the current row removeComment() * will return false and post an error. If you attempt to call removeComment() with no row loaded null will be returned. * If $pn_user_id is specified then only comments created by the specified user will be deleted; if the comment being * deleted is not created by the user then false is returned and an error posted. * * @param $pn_comment_id [integer] a valid comment_id to be removed; must be related to the currently loaded row (mandatory) * @param $pn_user_id [integer] a valid ca_users.user_id value; if specified then only comments by the specified user will be deleted (optional - default is null) */ public function removeComment($pn_comment_id, $pn_user_id = null) { if (!($vn_row_id = $this->getPrimaryKey())) { return null; } $t_comment = new ca_item_comments($pn_comment_id); if (!$t_comment->getPrimaryKey()) { $this->postError(2800, _t('Comment id is invalid'), 'BaseModel->removeComment()', 'ca_item_comments'); return false; } if ($t_comment->get('table_num') != $this->tableNum() || $t_comment->get('row_id') != $vn_row_id) { $this->postError(2810, _t('Comment is not part of the current row'), 'BaseModel->removeComment()', 'ca_item_comments'); return false; } if ($pn_user_id) { if ($t_comment->get('user_id') != $pn_user_id) { $this->postError(2820, _t('Comment was not created by specified user'), 'BaseModel->removeComment()', 'ca_item_comments'); return false; } } $t_comment->setMode(ACCESS_WRITE); $t_comment->delete(); if ($t_comment->numErrors()) { $this->errors = $t_comment->errors; return false; } return true; }
public function renderWidget($ps_widget_id, &$pa_settings) { parent::renderWidget($ps_widget_id, $pa_settings); global $g_ui_locale_id; if ($pa_settings["display_limit"] && intval($pa_settings["display_limit"]) > 0 && intval($pa_settings["display_limit"]) < 1000) { $vn_limit = intval($pa_settings["display_limit"]); } else { $vn_limit = 10; } $this->opo_view->setVar('limit', $vn_limit); $vn_show_type = intval($pa_settings["show_moderated_type"]); $vs_comment_type = ""; switch ($vn_show_type) { case 1: $vs_mode = "moderated"; $vs_comment_type = _t("moderated"); break; # --------------------------------------- # --------------------------------------- case 0: $vs_mode = "unmoderated"; $vs_comment_type = _t("unmoderated"); break; # --------------------------------------- # --------------------------------------- default: $vs_mode = ""; $vs_comment_type = ""; break; # --------------------------------------- } $this->opo_view->setVar('comment_type', $vs_comment_type); $t_comments = new ca_item_comments(); $va_comments = $t_comments->getComments($vs_mode, $vn_limit); $this->opo_view->setVar('comment_list', $va_comments); $this->opo_view->setVar('request', $this->getRequest()); $this->opo_view->setVar('settings', $pa_settings); return $this->opo_view->render('main_html.php'); }
function deleteComment() { if (!$this->request->isLoggedIn()) { $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'loginForm')); return; } $o_datamodel = new Datamodel(); if (!($t_set = $this->_getSet(__CA_SET_READ_ACCESS__))) { $this->Index(); return; } $pn_comment_id = $this->request->getParameter("comment_id", pInteger); $t_comment = new ca_item_comments($pn_comment_id); if ($t_comment->get("comment_id")) { # --- check if user is owner of comment or has edit access to set comment was made on if ($this->request->getUserID() != $t_comment->get("user_id") && !$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) { $this->Index(); return; } $t_comment->setMode(ACCESS_WRITE); $t_comment->delete(true); if ($t_comment->numErrors()) { $this->notification->addNotification(_t("There were errors:" . join("; ", $t_comment->getErrors())), __NOTIFICATION_TYPE_ERROR__); } else { $this->notification->addNotification(_t("Removed comment"), __NOTIFICATION_TYPE_INFO__); } } else { $this->notification->addNotification(_t("Invalid comment_id"), __NOTIFICATION_TYPE_ERROR__); } $ps_reload = $this->request->getParameter("reload", pString); switch ($ps_reload) { case "detail": $this->response->setRedirect(caNavUrl($this->request, '', 'Sets', 'setDetail')); return; break; # ----------------------------- # ----------------------------- default: $this->response->setRedirect(caNavUrl($this->request, '', 'Sets', 'Index')); return; break; # ----------------------------- } }
/** * Permanently deletes the comment specified by $pn_comment_id. * If $pn_user_id is specified then only comments created by the specified user will be deleted; if the comment being * deleted is not created by the user then false is returned and an error posted. * * @param $pn_comment_id [integer] a valid comment_id to be removed; must be related to the currently loaded row (mandatory) * @param $pn_user_id [integer] a valid ca_users.user_id value; if specified then only comments by the specified user will be deleted (optional - default is null) */ public function removeComment($pn_comment_id, $pn_user_id = null) { $t_comment = new ca_item_comments($pn_comment_id); if (!$t_comment->getPrimaryKey()) { $this->postError(2800, _t('Comment id is invalid'), 'BaseModel->removeComment()'); return false; } if ($pn_user_id) { if ($t_comment->get('user_id') != $pn_user_id) { $this->postError(2820, _t('Comment was not created by specified user'), 'BaseModel->removeComment()'); return false; } } $t_comment->setMode(ACCESS_WRITE); $t_comment->delete(); if ($t_comment->numErrors()) { $this->errors = $t_comment->errors; return false; } return true; }
public function DownloadMedia() { $pn_comment_id = $this->request->getParameter('comment_id', pString); $ps_field = $this->request->getParameter('field', pString); if (!$ps_field || !in_array($ps_field, array("media1", "media2", "media3", "media4"))) { $ps_field = "media1"; } $ps_mode = $this->request->getParameter('mode', pString); $ps_version = $this->request->getParameter('version', pString); $t_item_comment = new ca_item_comments($pn_comment_id); $va_versions = $t_item_comment->getMediaVersions($ps_field); if (!in_array($ps_version, $va_versions)) { $ps_version = $va_versions[0]; } if (!$t_item_comment->getMediaTag($ps_field, $ps_version)) { # --- redirect based on mode switch ($ps_mode) { case "list": $this->ListUnmoderated(); break; # ----------------------- # ----------------------- case "search": $this->Index(); break; # ----------------------- # ----------------------- case "dashboard": $this->response->setRedirect(caNavUrl($this->request, "", "Dashboard", "Index")); break; # ----------------------- } } else { $this->view->setVar('version_path', $t_item_comment->getMediaPath($ps_field, $ps_version)); $va_info = $t_item_comment->getMediaInfo($ps_field); $va_version_info = $t_item_comment->getMediaInfo($ps_field, $ps_version); if ($va_info['ORIGINAL_FILENAME']) { if ($ps_version == 'original') { if (!preg_match('!' . $va_version_info['EXTENSION'] . '$!i', $va_info['ORIGINAL_FILENAME'])) { $va_info['ORIGINAL_FILENAME'] .= '.' . $va_version_info['EXTENSION']; } $this->view->setVar('version_download_name', $va_info['ORIGINAL_FILENAME']); } else { $va_tmp = explode('.', $va_info['ORIGINAL_FILENAME']); if (sizeof($va_tmp) > 1) { array_pop($va_tmp); } $this->view->setVar('version_download_name', join('_', $va_tmp) . '.' . $va_version_info['EXTENSION']); } } else { $this->view->setVar('version_download_name', 'comment_media_' . $pn_comment_id . '_' . $ps_version . '.' . $va_version_info['EXTENSION']); } return $this->render('comment_download_binary.php'); } }
* WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * This source code is free and modifiable under the terms of * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See * the "license.txt" file for details, or visit the CollectiveAccess web site at * http://www.CollectiveAccess.org * * @package CollectiveAccess * @subpackage Core * @license http://www.gnu.org/copyleft/gpl.html GNU Public License version 3 * * ---------------------------------------------------------------------- */ require_once __CA_MODELS_DIR__ . "/ca_item_comments.php"; $t_item_comments = new ca_item_comments(); $va_comments = $t_item_comments->getComments("moderated", 2); $va_access_values = $this->getVar("access_values"); ?> <div class="row"> <div class="col-sm-6 border-right news"> <?php print caGetThemeGraphic($this->request, 'hp_news.jpg'); ?> <H1>News</H1> <H2>News Heading</H2> <H3>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc faucibus nunc nisi, eu sollicitudin nibh pellentesque non.</H3> </div><!--end col-sm-6--> <div class="col-sm-6"> <?php print $this->render("Front/featured_set_slideshow_html.php");