本文整理汇总了PHP中comment::save方法的典型用法代码示例。如果您正苦于以下问题:PHP comment::save方法的具体用法?PHP comment::save怎么用?PHP comment::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comment
的用法示例。
在下文中一共展示了comment::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
public function addAction()
{
if (user::isGuest() && reg::getKey('/comments/only_reg')) {
system::stop();
}
if (user::isGuest() && !system::validCapcha('random_image')) {
system::json(array('error' => 1, 'data' => lang::get('FEEDBACK_ERROR1')));
}
// Добавляем новый комментарий
$comment = new comment();
$comment->setParentId(system::POST('parent_id'));
$comment->setObjId(system::POST('obj_id'));
$comment->setUserName(system::POST('username'));
$comment->setEmail(system::POST('email'));
$comment->setText(system::POST('text'));
$comment->setSendEmail(system::POST('send_email'));
$obj_id = $comment->save();
if ($obj_id) {
page::assign('current_url', system::POST('back_url'));
$html = page::macros('comments')->view($comment->id());
system::json(array('error' => 0, 'data' => $html));
} else {
system::json(array('error' => 2, 'data' => $comment->getErrorListText(' ')));
}
if (!empty($_POST['back_url']) && !system::isAjax()) {
system::redirect($_POST['back_url'] . '#comment' . $obj_id, true);
} else {
system::stop();
}
}
示例2: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request, $postId)
{
$comment = new comment();
$comment->message = $request->message;
$comment->author_id = Auth::user()->id;
$comment->insertion_id = $postId;
$comment->save();
return view('posts.show', ['show' => $postId]);
}
示例3: foreach
function update_mime_parts($commentID, $files)
{
$x = 2;
// mime part 1 will be the message text
foreach ((array) $files as $file) {
$bits = array();
$bits["part"] = $file["part"] or $bits["part"] = $x++;
$bits["name"] = $file["name"];
$bits["size"] = $file["size"];
$mimebits[] = $bits;
}
if ($commentID && $mimebits) {
$comment = new comment($commentID);
$comment->set_value("commentMimeParts", serialize($mimebits));
$comment->skip_modified_fields = true;
$comment->updateSearchIndexLater = true;
$comment->save();
}
}
示例4: addComment
public function addComment($urlfriendly = null)
{
$C = new configuration();
$codice = $C->getBlogConfiguration();
if ($this->data) {
if (is_null($urlfriendly) === true) {
$this->redirect($codice['blog_siteurl'], true);
}
$P = new post();
$post = $P->findBy('urlfriendly', $urlfriendly);
if ($P->isNew() === true) {
$this->redirect($codice['blog_siteurl'], true);
}
if (isset($this->data["resultado"]) === true) {
$captcha = $this->data['resultado'];
if ($captcha != '5') {
$this->session->flash('Tu comentario no puede ser agregado. Necesitas contestar la pregunta correctamente.');
$this->redirect("{$post['urlfriendly']}#comments");
}
unset($this->data['resultado']);
} else {
$this->session->flash('Tu comentario no puede ser agregado. Necesitas contestar la pregunta.');
$this->redirect("{$post['urlfriendly']}#comments");
}
if ($this->cookie->check('id_user')) {
$this->data['user_id'] = $this->cookie->id_user;
$this->data['status'] = 'publish';
} else {
$this->data['user_id'] = 0;
$this->data['status'] = 'waiting';
}
$this->data['type'] = '';
//'pingback', 'trackback', ''
$this->data['IP'] = utils::getIP();
$this->data['ID_post'] = $post["ID"];
$this->cookie->author = $this->data['author'];
$this->cookie->email = $this->data['email'];
$this->cookie->url = $this->data['url'];
$C = new comment();
$C->prepareFromArray($this->data);
$valid = $C->save();
if ($valid) {
$this->registry->lastCommentID = $valid;
$this->registry->postID = $post["ID"];
$this->plugin->call("index_comment_added");
}
if ($valid and $this->isAjax()) {
echo $valid;
} else {
if ($valid) {
$this->redirect("{$post['urlfriendly']}#comment-{$valid}");
} else {
$this->redirect("{$post['urlfriendly']}");
}
}
}
}
示例5: approve
public function approve($id)
{
$Comment = new comment();
$Comment->find($id);
if ($Comment['type'] == 'pingback' or $Comment['type'] == 'trackback') {
$Comment->setPingback();
}
$Comment['status'] = 'publish';
$Comment->save();
$this->registry->lastCommentID = $id;
$this->plugin->call("comment_approbed");
if ($this->isAjax()) {
echo $id;
} else {
$this->redirect("comments");
}
}
示例6: import_planner_tasks
function import_planner_tasks($parentNode, $parentTaskId, $depth, $task_allocation, $resource_people, $project_manager_ID)
{
//Recursively imports tasks from GNOME Planner, given the parentNode.
global $projectID;
$current_user =& singleton("current_user");
$result = array();
// our dodgy DOM_NodeList doesn't support foreach....
for ($i = 0; $i < $parentNode->childNodes->length; $i++) {
$taskXML = $parentNode->childNodes->item($i);
if ($taskXML->nodeType == XML_ELEMENT_NODE && $taskXML->tagName == "task") {
$task = new task();
$task->set_value('taskName', trim($taskXML->getAttribute("name")));
$task->set_value('projectID', $projectID);
// We can find the task assignee's id in the $task_allocation array, and that person's Person record in the $resource_people array
$planner_taskid = $taskXML->getAttribute("id");
// Dates we guess at (i.e., set to now)
$task->set_value('dateCreated', date("Y-m-d H:i:s"));
$task->set_value('dateAssigned', date("Y-m-d H:i:s"));
if ($taskXML->hasAttribute("work-start")) {
$task->set_value('dateTargetStart', import_planner_date($taskXML->getAttribute("work-start")));
} else {
$task->set_value('dateTargetStart', import_planner_date($taskXML->getAttribute("start")));
$result[] = "Resorting to work value for " . $task->get_value('taskName');
}
$task->set_value('dateTargetCompletion', import_planner_date($taskXML->getAttribute("end")));
if ($taskXML->hasAttribute("note")) {
$task->set_value('taskDescription', $taskXML->getAttribute("note"));
}
$task->set_value('creatorID', $current_user->get_id());
$task->set_value('managerID', $project_manager_ID);
if ($taskXML->hasAttribute("type") and $taskXML->getAttribute("type") == "milestone") {
$task->set_value('taskTypeID', 'Milestone');
} else {
$task->set_value('taskTypeID', 'Task');
}
$task->set_value('taskStatus', 'open_notstarted');
$task->set_value('priority', '3');
$task->set_value('parentTaskID', $parentTaskId == 0 ? "" : $parentTaskId);
// The following fields we leave at their default values: duplicateTaskID, dateActualCompletion, dateActualStart, closerID, timeExpected, dateClosed, parentTaskID, taskModifiedUser
// Handle task assignment
if (isset($task_allocation[$planner_taskid])) {
if (is_array($task_allocation[$planner_taskid])) {
// This task was assigned to more than one person. Assign it to the project manager and make a comment about it.
$task->set_value('personID', $project_manager_ID);
// Save the task so we have a task ID
$task->save();
// Make a comment about this task
$comment = new comment();
$comment->set_value("commentType", "task");
$comment->set_value("commentLinkID", $task->get_id());
$comment->set_value("commentCreatedTime", date("Y-m-d H:i:s"));
// The user doing the import is (implicitly) the user creating the comment
$comment->set_value("commentCreatedUser", $current_user->get_id());
// Get the relevant usernames
$names = array();
foreach ($task_allocation[$planner_taskid] as $assignee) {
$names[] = person::get_fullname($assignee);
}
$comment->set_value("comment", "Import notice: This task was originally assigned to " . implode($names, ', ') . ".");
$comment->save();
$result[] = sprintf("<li>Note: multiple people were assigned to the task %d %s</li>", $task->get_id(), $task->get_value("taskName"));
} else {
$task->set_value('personID', $resource_people[$task_allocation[$taskXML->getAttribute("id")]]->get_id());
}
} else {
// Task not assigned to anyone, assign the task to the nominated manager
$task->set_value('personID', $project_manager_ID);
}
$task->save();
$result[] = sprintf('<li>%sCreated task <a href="%s">%d %s</a>.</li>', str_repeat(">", $depth), $task->get_url(), $task->get_id(), $task->get_value('taskName'));
// Do child nodes
if ($taskXML->hasChildNodes()) {
$result = array_merge($result, import_planner_tasks($taskXML, $task->get_id(), $depth + 1, $task_allocation, $resource_people, $project_manager_ID));
}
}
}
return $result;
}
示例7: nvweb_comments
function nvweb_comments($vars = array())
{
global $website;
global $DB;
global $current;
global $webgets;
global $dictionary;
global $webuser;
global $theme;
global $events;
global $session;
$webget = 'comments';
if (!isset($webgets[$webget])) {
$webgets[$webget] = array();
global $lang;
if (empty($lang)) {
$lang = new language();
$lang->load($current['lang']);
}
// default translations
$webgets[$webget]['translations'] = array('post_a_comment' => t(379, 'Post a comment'), 'name' => t(159, 'Name'), 'email' => t(44, 'E-Mail'), 'website' => t(177, 'Website'), 'message' => t(380, 'Message'), 'email_will_not_be_published' => t(381, 'E-Mail will not be published'), 'submit' => t(382, 'Submit'), 'sign_in_or_sign_up_to_post_a_comment' => t(383, 'Sign in or Sign up to post a comment'), 'comments_on_this_entry_are_closed' => t(384, 'Comments on this entry are closed'), 'please_dont_leave_any_field_blank' => t(385, 'Please don\'t leave any field blank'), 'your_comment_has_been_received_and_will_be_published_shortly' => t(386, 'Your comment has been received and will be published shortly'), 'new_comment' => t(387, 'New comment'), 'review_comments' => t(388, 'Review comments'));
// theme translations
// if the web theme has custom translations for this string subtypes, use it (for the user selected language)
/* just add the following translations to your json theme dictionary:
"post_a_comment": "Post a comment",
"name": "Name",
"email": "E-Mail",
"website": "Website",
"message": "Message",
"email_will_not_be_published": "E-Mail will not be published",
"submit": "Submit",
"sign_in_or_sign_up_to_post_a_comment": "Sign in or Sign up to post a comment",
"comments_on_this_entry_are_closed": "Comments on this entry are closed",
"please_dont_leave_any_field_blank": "Please don't leave any field blank",
"your_comment_has_been_received_and_will_be_published_shortly": "Your comment has been received and will be published shortly",
"new_comment": "New comment",
"review_comments": "Review comments"
*/
if (!empty($website->theme) && method_exists($theme, 't')) {
foreach ($webgets[$webget]['translations'] as $code => $text) {
$theme_translation = $theme->t($code);
if (!empty($theme_translation) && $theme_translation != $code) {
$webgets[$webget]['translations'][$code] = $theme_translation;
}
}
}
}
// set default callback
if (empty($vars['callback'])) {
$vars['callback'] = 'alert';
}
// check callback attributes
$callback = $vars['callback'];
if (!empty($vars['alert_callback'])) {
$callback = $vars['alert_callback'];
} else {
if (!empty($vars['callback_alert'])) {
$callback = $vars['callback_alert'];
}
}
$callback_error = $callback;
if (!empty($vars['error_callback'])) {
$callback_error = $vars['error_callback'];
} else {
if (!empty($vars['callback_error'])) {
$callback_error = $vars['callback_error'];
}
}
$out = '';
// if the current page belongs to a structure entry
// we need to get the associated elements to retrieve and post its comments
// (because structure entry pages can't have associated comments)
// so, ONLY the FIRST element associated to a category can have comments in a structure entry page
// (of course if the element has its own page, it can have its own comments)
$element = $current['object'];
if ($current['type'] == 'structure') {
if (empty($current['structure_elements'])) {
$current['structure_elements'] = $element->elements();
}
$element = $current['structure_elements'][0];
}
switch (@$vars['mode']) {
case 'process':
if (isset($_GET['nv_approve_comment'])) {
// process 1-click comment approval
$comment = new comment();
$comment->load($_GET['id']);
if (!empty($comment->id) && $comment->status == -1) {
$hash = $_GET['hash'];
if ($hash == sha1($comment->id . $comment->email . APP_UNIQUE . serialize($website->contact_emails))) {
// hash check passed
$comment->status = 0;
$comment->save();
$response = t(555, "Item has been successfully published.");
if ($vars['notify'] == 'inline' || $callback == 'inline') {
$out = '<div class="comment-success">' . $response . '</div>';
} else {
if (!isset($vars['notify']) || $vars['notify'] == 'callback') {
nvweb_after_body("js", $callback . '("' . $response . '");');
//.........这里部分代码省略.........
示例8: comment
$client->set_value("clientStateOne", $data[5]);
$client->set_value("clientPostcodeOne", $data[6]);
$client->set_value("clientStreetAddressTwo", $data[7]);
$client->set_value("clientSuburbTwo", $data[8]);
$client->set_value("clientStatus", "current");
$client->set_value("clientModifiedUser", $current_user->get_id());
$client->save();
if ($client->get_id()) {
if (rtrim($data[9])) {
$comment = new comment();
$comment->set_value("commentMaster", "client");
$comment->set_value("commentMasterID", $client->get_id());
$comment->set_value("commentType", "client");
$comment->set_value("commentLinkID", $client->get_id());
$comment->set_value("comment", $data[9]);
$comment->save();
$comment_id = $comment->get_id();
}
if ($data[10] || $data[11]) {
$cc = new clientContact();
$cc->set_value("clientID", $client->get_id());
$cc->set_value("primaryContact", 1);
$cc->set_value("clientContactName", $data[10]);
$cc->set_value("clientContactEmail", $data[11]);
$cc->save();
$cc_id = $cc->get_id();
}
}
$x++;
echo "<br>" . $client->get_id() . " --- " . $cc_id . " --- " . $comment_id;
if ($x > 4) {