function handlePOST_submitAbuse($request_data)
 {
     global $error_msg;
     if ($request_data['action'] == 'submitAbuse' && !empty(PA::$login_uid)) {
         filter_all_post($request_data);
         $abuse = trim($request_data['abuse']);
         $type = isset($request_data['type']) && $request_data['type'] == 'comment' ? 'comment' : 'content';
         $mail_type = $type == 'comment' ? "report_abuse_on_comment" : "report_abuse_on_content";
         if (!empty($abuse)) {
             $extra = $this->shared_data['extra'];
             $network_info = $this->shared_data['network_info'];
             $error_msg = "";
             try {
                 // Saving the abuse report
                 $report_abuse_obj = new ReportAbuse();
                 $report_abuse_obj->parent_type = $type == 'comment' ? TYPE_COMMENT : TYPE_CONTENT;
                 $report_abuse_obj->parent_id = $request_data['cid'];
                 $report_abuse_obj->reporter_id = PA::$login_uid;
                 $report_abuse_obj->body = $request_data['abuse'];
                 $id = $report_abuse_obj->save();
             } catch (PAException $e) {
                 $error_msg = $e->message;
             }
             $ccid_string = "";
             PANotify::send($mail_type, PA::$network_info, PA::$login_user, $report_abuse_obj);
             $error_msg = 9002;
             /*
                     if(!empty($request_data['gid'])) {
                       $group = new Group();
                       $group->load((int)$request_data['gid']);
                       PANotify::send("report_abuse_grp_owner", $group, PA::$login_user, $report_abuse_obj);
                     }
             */
             try {
                 if (!empty($this->shared_data['content']) && !empty($this->shared_data['collection'])) {
                     $content = $this->shared_data['content'];
                     $collection = $this->shared_data['collection'];
                     if ($content && $content->parent_collection_id != -1) {
                         if ($this->shared_data['is_group_content']) {
                             $mail_type = $type == 'comment' ? "report_abuse_on_comment_grp_owner" : "report_abuse_grp_owner";
                             PANotify::send($mail_type, $this->shared_data['collection'], PA::$login_user, $report_abuse_obj);
                             $error_msg = 9002;
                         }
                     }
                 }
             } catch (PAException $e) {
                 $error_msg = $e->message;
             }
         } else {
             $error_msg = 9004;
         }
     }
 }
function total_abuse($id, $type)
{
    $report_abuse_obj = new ReportAbuse();
    $report_abuse_obj->parent_type = $type;
    $report_abuse_obj->parent_id = $id;
    $result = $report_abuse_obj->get_multiples();
    return count($result);
}
Пример #3
0
 function render_for_ajax()
 {
     $op = $this->params["op"];
     // if (empty(PA::$login_user) && $op != "paging") return __("Login required");
     switch ($op) {
         case "flagthis":
             if (empty(PA::$login_user)) {
                 $this->err = __("Please log in or register to flag a review!");
                 break;
             }
             // file the abuse report
             try {
                 list($foo, $review_id) = split(':', $this->params['flag']);
                 $abuse_obj = new ReportAbuse();
                 $abuse_obj->parent_type = 'review';
                 $abuse_obj->parent_id = $review_id;
                 $abuse_obj->reporter_id = PA::$login_uid;
                 // TODO: possibly make this user input
                 $abuse_obj->body = "This review was flagged.";
                 $id = $abuse_obj->save();
                 $this->note = "Your abuse report was filed.";
             } catch (PAException $e) {
                 $this->err = __("There was a problem flagging this review: ") . $e->message;
             }
             break;
         case "add_review":
             do {
                 if (empty(PA::$login_user)) {
                     $this->err = __("Please log in or register to add a review!");
                     break;
                 }
                 $body = trim($this->params["body"]);
                 if (empty($body)) {
                     $this->err = __("Please enter a review!");
                     break;
                 }
                 // validation done - now save the review
                 $rev = new Review();
                 $rev->author_id = PA::$login_user->user_id;
                 $rev->subject_type = $this->params["subject_type"];
                 $rev->subject_id = $this->params["subject_id"];
                 $rev->title = "";
                 // $title;
                 $rev->body = $body;
                 if (!$rev->save()) {
                     $this->err = __("Save failed.");
                     break;
                 }
                 $this->note = __("Review added - thank you for participating!");
                 // handle tags
                 $tags = trim($this->params["tags"]);
                 if (!empty($tags)) {
                     $tags_array = preg_split('/\\s*,\\s*/', $tags);
                     ItemTags::save_tags_for_item(PA::$login_user->user_id, $this->params["subject_type"], $this->params["subject_id"], $tags_array);
                 }
                 // for rivers of people
                 $activity = 'user_post_a_review';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' posted a review.', 'subject_type' => $rev->subject_type, 'subject_id' => $rev->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } while (0);
             break;
         default:
             // just ignore unknown ops
             break;
     }
     return $this->render();
 }
Пример #4
0
 public function testGet_multiples_with_ReportId()
 {
     $report_abuse_obj = new ReportAbuse();
     $report_abuse_obj->report_id = 2;
     $result = $report_abuse_obj->get_multiples();
     $field = 'report_id = ?';
     $sql = "SELECT report_id, parent_type, parent_id, body, created, reporter_id\n            FROM {report_abuse} \n            WHERE {$field}";
     $data = array($report_abuse_obj->report_id);
     $res = Dal::query($sql, $data);
     $test_result = array();
     if ($res->numRows()) {
         while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
             $test_result[] = $row;
         }
     }
     $this->assertEquals($result, $test_result);
 }
Пример #5
0
                    }
                }
            } catch (PAException $e) {
                //catch none
            }
        } else {
            $error_message = 9004;
        }
    }
}
// Code for sending Email to Network owner for abuse content..
if (!empty($_POST['rptabuse']) && !empty(PA::$login_uid) && !isset($_POST['type'])) {
    $error_message = "";
    try {
        // Saving the abuse report
        $report_abuse_obj = new ReportAbuse();
        $report_abuse_obj->parent_type = TYPE_CONTENT;
        $report_abuse_obj->parent_id = $_GET["cid"];
        $report_abuse_obj->reporter_id = PA::$login_uid;
        $report_abuse_obj->body = $_POST['abuse'];
        $id = $report_abuse_obj->save();
    } catch (PAException $e) {
        $error_message = $e->message;
    }
    $ccid_string = "";
    if (!empty($_POST['ccid'])) {
        $ccid_string = "&ccid=" . $_POST['ccid'];
    }
    $abuse = trim($_POST['abuse']);
    if (!empty($abuse)) {
        if ($_SESSION['user']['id']) {
                }
            } catch (PAException $e) {
                //catch none
            }
        } else {
            $error_message = 9004;
        }
    }
}
// Code for sending Email to Network owner for abuse content..
$ccid_string = "";
if (!empty($_POST['rptabuse']) && !empty(PA::$login_uid) && !isset($_POST['type'])) {
    $error_message = "";
    try {
        // Saving the abuse report
        $report_abuse_obj = new ReportAbuse();
        $report_abuse_obj->parent_type = TYPE_CONTENT;
        $report_abuse_obj->parent_id = $_GET["cid"];
        $report_abuse_obj->reporter_id = PA::$login_uid;
        $report_abuse_obj->body = $_POST['abuse'];
        $id = $report_abuse_obj->save();
    } catch (PAException $e) {
        $error_message = $e->message;
    }
    $ccid_string = "";
    if (!empty($_POST['ccid'])) {
        $ccid_string = "&ccid=" . $_POST['ccid'];
    }
    $abuse = trim($_POST['abuse']);
    if (!empty($abuse)) {
        PANotify::send("report_abuse_on_content", PA::$network_info, PA::$login_user, $report_abuse_obj);
Пример #7
0
 function render_for_ajax()
 {
     $op = $this->params["op"];
     // if ($op != 'paging' && empty(PA::$login_user)) return __("Login required");
     switch ($op) {
         case "flagthis":
             if (empty(PA::$login_user)) {
                 $this->err = __("Please log in or register to flag a comment!");
                 break;
             }
             // file the abuse report
             try {
                 list($foo, $comment_id) = split(':', $this->params['flag']);
                 $abuse_obj = new ReportAbuse();
                 $abuse_obj->parent_type = 'comment';
                 $abuse_obj->parent_id = $comment_id;
                 $abuse_obj->reporter_id = PA::$login_uid;
                 // TODO: possibly make this user input
                 $abuse_obj->body = "This comment was flagged.";
                 $id = $abuse_obj->save();
                 $this->note = "Your abuse report was filed.";
             } catch (PAException $e) {
                 $this->err = __("There was a problem flagging this comment: ") . $e->message;
             }
             break;
         case "add_comment":
             do {
                 if (empty(PA::$login_user)) {
                     $this->err = __("Please log in or register to post enter a comment!");
                     break;
                 }
                 // $title = trim($this->params["title"]);
                 // if (empty($title)) { $this->err = "Please give your comment a title."; break; }
                 $body = trim($this->params["body"]);
                 if (empty($body)) {
                     $this->err = "Please enter a comment!";
                     break;
                 }
                 // validation done - now save the comment
                 $comm = new Comment2();
                 $comm->author_id = PA::$login_user->user_id;
                 $comm->subject_type = $this->params["subject_type"];
                 $comm->subject_id = $this->params["subject_id"];
                 $comm->title = $title;
                 $comm->body = $body;
                 if (!$comm->save()) {
                     $this->err = __("Save failed.");
                     break;
                 }
                 $this->note = __("Comment added - thank you for participating!");
                 // for rivers of people
                 $activity = 'user_post_a_comment';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' posted a comment.', 'subject_type' => $comm->subject_type, 'subject_id' => $comm->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } while (0);
             break;
         default:
             // just ignore any others
             break;
     }
     return $this->render();
 }