Exemple #1
0
 /**
  * Save a reply
  *
  * @return     void
  */
 private function savereply()
 {
     // Check for request forgeries
     Request::checkToken();
     // Is the user logged in?
     if (User::isGuest()) {
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_LOGIN_NOTICE'));
         return;
     }
     $publication =& $this->publication;
     // Trim and addslashes all posted items
     $comment = Request::getVar('comment', array(), 'post', 'none', 2);
     if (!$publication->exists()) {
         // Cannot proceed
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_COMMENT_ERROR_NO_REFERENCE_ID'));
         return;
     }
     $database = App::get('db');
     $row = new \Hubzero\Item\Comment($database);
     if (!$row->bind($comment)) {
         $this->setError($row->getError());
         return;
     }
     $message = $row->id ? Lang::txt('PLG_PUBLICATIONS_REVIEWS_EDITS_SAVED') : Lang::txt('PLG_PUBLICATIONS_REVIEWS_COMMENT_POSTED');
     // Perform some text cleaning, etc.
     $row->content = \Hubzero\Utility\Sanitize::clean($row->content);
     $row->anonymous = $row->anonymous == 1 || $row->anonymous == '1' ? $row->anonymous : 0;
     $row->created = $row->id ? $row->created : Date::toSql();
     $row->state = $row->id ? $row->state : 0;
     $row->created_by = $row->id ? $row->created_by : User::get('id');
     // Check for missing (required) fields
     if (!$row->check()) {
         $this->setError($row->getError());
         return;
     }
     // Save the data
     if (!$row->store()) {
         $this->setError($row->getError());
         return;
     }
     // Redirect
     App::redirect(Route::url($publication->link('reviews')), $message);
 }
Exemple #2
0
 /**
  * Mark a comment as deleted
  * NOTE: Does not actually delete data. Simply marks record.
  *
  * @return    void
  */
 protected function _delete()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $this->_login();
     }
     // Incoming
     $id = Request::getInt('comment', 0);
     if (!$id) {
         return $this->_redirect();
     }
     // Initiate a blog comment object
     $comment = new \Hubzero\Item\Comment($this->database);
     $comment->load($id);
     if (User::get('id') != $comment->created_by && !$this->params->get('access-delete-comment')) {
         App::redirect($this->url);
         return;
     }
     // Delete the entry itself
     if (!$comment->setState($id, 2)) {
         $this->setError($comment->getError());
     }
     App::redirect($this->url, Lang::txt('PLG_COURSES_REVIEWS_REMOVED'), 'message');
 }
 /**
  * Delete a comment
  *
  * @return     string
  */
 private function _deletecomment()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         return $this->_login();
     }
     // Incoming
     $id = Request::getInt('comment', 0);
     if (!$id) {
         return $this->_post();
     }
     // Initiate a whiteboard comment object
     $comment = new \Hubzero\Item\Comment($this->database);
     $comment->load($id);
     $comment->state = 2;
     // Delete the entry itself
     if (!$comment->store()) {
         $this->setError($comment->getError());
     }
     // Return the topics list
     return $this->_post();
 }
Exemple #4
0
 /**
  * Removes an item reported as abusive
  *
  * @param      integer $referenceid ID of the database table row
  * @param      integer $parentid    If the element has a parent element
  * @param      string  $category    Element type (determines table to look in)
  * @param      string  $message     Message to user to append to
  * @return     string
  */
 public function deleteReportedItem($referenceid, $parentid, $category, $message)
 {
     if (!$this->_canHandle($category)) {
         return null;
     }
     $this->loadLanguage();
     $database = App::get('db');
     switch ($category) {
         case 'wish':
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wishlist.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wish' . DS . 'plan.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'owner.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'ownergroup.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wish.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wish' . DS . 'rank.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wish' . DS . 'attachment.php';
             // Delete the wish
             $wish = new \Components\Wishlist\Tables\Wish($database);
             $wish->delete_wish($referenceid);
             // also delete all votes for this wish
             $objR = new \Components\Wishlist\Tables\Rank($database);
             $objR->remove_vote($referenceid);
             $message .= Lang::txt('PLG_SUPPORT_WISHLIST_NOTIFICATION_OF_WISH_REMOVAL', $parentid);
             break;
         case 'wishcomment':
             $comment = new \Hubzero\Item\Comment($database);
             $comment->load($referenceid);
             $comment->state = 2;
             if (!$comment->store()) {
                 $this->setError($comment->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_WISHLIST_NOTIFICATION_OF_COMMENT_REMOVAL', $parentid);
             break;
     }
     return $message;
 }
Exemple #5
0
 /**
  * Removes an item reported as abusive
  *
  * @param      integer $referenceid ID of the database table row
  * @param      integer $parentid    If the element has a parent element
  * @param      string  $category    Element type (determines table to look in)
  * @param      string  $message     Message to user to append to
  * @return     string
  */
 public function deleteReportedItem($referenceid, $parentid, $category, $message)
 {
     if (!$this->_canHandle($category)) {
         return null;
     }
     $database = App::get('db');
     switch ($category) {
         case 'answer':
             $database->setQuery("UPDATE `#__answers_responses` SET state='2' WHERE id=" . $referenceid);
             if (!$database->query()) {
                 $this->setError($database->getErrorMsg());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_ANSWERS_NOTIFY_ANSWER_REMOVED', $parentid);
             break;
         case 'question':
             $upconfig = Component::params('com_members');
             $banking = $upconfig->get('bankAccounts');
             $reward = 0;
             if ($banking) {
                 $reward = $this->getReward($parentid);
             }
             $responders = array();
             // Get all the answers for this question
             $database->setQuery("SELECT r.id, r.created_by FROM `#__answers_responses` AS r WHERE r.question_id=" . $referenceid);
             $answers = $database->loadObjectList();
             if ($answers) {
                 foreach ($answers as $answer) {
                     // Delete response
                     $database->setQuery("UPDATE `#__answers_responses` SET state='2' WHERE id=" . $answer->id);
                     if (!$database->query()) {
                         $this->setError($database->getErrorMsg());
                         return false;
                     }
                     // Collect responders names
                     $responders[] = $answer->created_by;
                 }
             }
             $database->setQuery("UPDATE `#__answers_questions` SET state='2', reward='0' WHERE id=" . $referenceid);
             if (!$database->query()) {
                 $this->setError($database->getErrorMsg());
                 return false;
             }
             if ($banking && $reward) {
                 // Send email to people who answered question with reward
                 if ($responders) {
                     foreach ($responders as $r) {
                         $zuser = User::getInstance($r);
                         if (is_object($zuser)) {
                             if (\Components\Support\Helpers\Utilities::checkValidEmail($zuser->get('email')) && $email) {
                                 $admin_email = Config::get('mailfrom');
                                 $sub = Lang::txt('PLG_SUPPORT_ANSWERS_SUBJECT', Config::get('sitename'), $referenceid);
                                 $from = Lang::txt('PLG_SUPPORT_ANSWERS_TITLE', Config::get('sitename'));
                                 $hub = array('email' => $admin_email, 'name' => $from);
                                 $mes = Lang::txt('PLG_SUPPORT_ANSWERS_BODY') . "\r\n";
                                 $mes .= '----------------------------' . "\r\n\r\n";
                                 $mes .= Lang::txt('PLG_SUPPORT_ANSWERS_QUESTION', $referenceid) . "\r\n";
                                 \Components\Support\Helpers\Utilities::sendEmail($hub, $zuser->get('email'), $sub, $mes);
                             }
                         }
                     }
                 }
                 // get id of asker
                 $database->setQuery("SELECT created_by FROM `#__answers_questions` WHERE id=" . $parentid);
                 $asker = $database->loadResult();
                 if ($asker) {
                     $quser = User::getInstance($asker);
                     if (is_object($quser)) {
                         $asker_id = $quser->get('id');
                     }
                     if (isset($asker_id)) {
                         // Remove hold
                         $sql = "DELETE FROM `#__users_transactions` WHERE category='answers' AND type='hold' AND referenceid=" . $parentid . " AND uid='" . $asker_id . "'";
                         $database->setQuery($sql);
                         if (!$database->query()) {
                             $this->setError($database->getErrorMsg());
                             return false;
                         }
                         // Make credit adjustment
                         $BTL_Q = new \Hubzero\Bank\Teller($database, $asker_id);
                         $credit = $BTL_Q->credit_summary();
                         $adjusted = $credit - $reward;
                         $BTL_Q->credit_adjustment($adjusted);
                     }
                 }
             }
             $message .= Lang::txt('PLG_SUPPORT_ANSWERS_NOTIFY_QUESTION_REMOVED', $parentid);
             break;
         case 'answercomment':
             $comment = new \Hubzero\Item\Comment($database);
             $comment->load($referenceid);
             $comment->state = 2;
             if (!$comment->store()) {
                 $this->setError($comment->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_ANSWERS_NOTIFY_COMMENT_REMOVED', $parentid);
             break;
     }
     return $message;
 }
Exemple #6
0
 /**
  * Save a reply
  *
  * @return     void
  */
 private function savereply()
 {
     // Check for request forgeries
     Request::checkToken();
     // Is the user logged in?
     if (User::isGuest()) {
         $this->setError(Lang::txt('PLG_RESOURCES_REVIEWS_LOGIN_NOTICE'));
         return;
     }
     // Incoming
     $id = Request::getInt('id', 0);
     // Trim and addslashes all posted items
     $comment = Request::getVar('comment', array(), 'post', 'none', 2);
     if (!$id) {
         // Cannot proceed
         $this->setError(Lang::txt('PLG_RESOURCES_REVIEWS_COMMENT_ERROR_NO_REFERENCE_ID'));
         return;
     }
     $database = App::get('db');
     $row = new \Hubzero\Item\Comment($database);
     if (!$row->bind($comment)) {
         $this->setError($row->getError());
         return;
     }
     // Perform some text cleaning, etc.
     $row->content = \Hubzero\Utility\Sanitize::stripImages(\Hubzero\Utility\Sanitize::clean($row->content));
     //$row->content    = nl2br($row->content);
     $row->anonymous = $row->anonymous == 1 || $row->anonymous == '1' ? $row->anonymous : 0;
     $row->created = $row->id ? $row->created : Date::toSql();
     $row->state = $row->id ? $row->state : 0;
     $row->created_by = $row->id ? $row->created_by : User::get('id');
     // Check for missing (required) fields
     if (!$row->check()) {
         $this->setError($row->getError());
         return;
     }
     // Save the data
     if (!$row->store()) {
         $this->setError($row->getError());
         return;
     }
 }
 /**
  * Removes an item reported as abusive
  *
  * @param      integer $referenceid ID of the database table row
  * @param      integer $parentid    If the element has a parent element
  * @param      string  $category    Element type (determines table to look in)
  * @param      string  $message     Message to user to append to
  * @return     string
  */
 public function deleteReportedItem($referenceid, $parentid, $category, $message)
 {
     if (!$this->_canHandle($category)) {
         return null;
     }
     $this->loadLanguage();
     $database = App::get('db');
     switch ($category) {
         case 'review':
             include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'resource.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'review.php';
             // Delete the review
             $review = new \Components\Resources\Tables\Review($database);
             $review->load($referenceid);
             $review->state = 2;
             $review->store();
             // Recalculate the average rating for the parent resource
             $resource = new \Components\Resources\Tables\Resource($database);
             $resource->load($parentid);
             $resource->calculateRating();
             if (!$resource->store()) {
                 $this->setError($resource->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_RESOURCES_NOTIFICATION_OF_REMOVAL', $parentid);
             break;
         case 'reviewcomment':
             $comment = new \Hubzero\Item\Comment($database);
             $comment->load($referenceid);
             $comment->state = 2;
             if (!$comment->store()) {
                 $this->setError($comment->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_RESOURCES_NOTIFICATION_OF_REMOVAL', $parentid);
             break;
     }
     return $message;
 }
 /**
  * Removes an item reported as abusive
  *
  * @param      integer $referenceid ID of the database table row
  * @param      integer $parentid    If the element has a parent element
  * @param      string  $category    Element type (determines table to look in)
  * @param      string  $message     Message to user to append to
  * @return     string
  */
 public function deleteReportedItem($referenceid, $parentid, $category, $message)
 {
     if ($category != 'pubreview' && $category != 'pubreviewcomment') {
         return null;
     }
     $this->loadLanguage();
     $msg = Lang::txt('PLG_SUPPORT_PUBLICATIONS_CONTENT_FOUND_OBJECTIONABLE');
     $database = App::get('db');
     switch ($category) {
         case 'review':
             include_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'publication.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'review.php';
             // Delete the review
             $review = new PublicationReview($database);
             $review->load($referenceid);
             //$comment->anonymous = 1;
             if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $review->comment, $matches)) {
                 $format = strtolower(trim($matches[1]));
                 switch ($format) {
                     case 'html':
                         $review->comment = '<!-- {FORMAT:HTML} --><span class="warning">' . $msg . '</span>';
                         break;
                     case 'wiki':
                     default:
                         $review->comment = '<!-- {FORMAT:WIKI} -->[[Span(' . $msg . ', class="warning")]]';
                         break;
                 }
             } else {
                 $review->comment = '[[Span(' . $msg . ', class="warning")]]';
             }
             $review->store();
             // Recalculate the average rating for the parent resource
             $pub = new Publication($database);
             $pub->load($parentid);
             $pub->calculateRating();
             $pub->updateRating();
             if (!$pub->store()) {
                 $this->setError($pub->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_PUBLICATIONS_NOTIFICATION_OF_REMOVAL', $parentid);
             break;
         case 'reviewcomment':
             $comment = new \Hubzero\Item\Comment($database);
             $comment->load($referenceid);
             //$comment->state = 2;
             if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $comment->content, $matches)) {
                 $format = strtolower(trim($matches[1]));
                 switch ($format) {
                     case 'html':
                         $comment->content = '<!-- {FORMAT:HTML} --><span class="warning">' . $msg . '</span>';
                         break;
                     case 'wiki':
                     default:
                         $comment->content = '<!-- {FORMAT:WIKI} -->[[Span(' . $msg . ', class="warning")]]';
                         break;
                 }
             } else {
                 $comment->content = '[[Span(' . $msg . ', class="warning")]]';
             }
             if (!$comment->store()) {
                 $this->setError($comment->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_PUBLICATIONS_NOTIFICATION_OF_REMOVAL', $parentid);
             break;
     }
     return $message;
 }