Пример #1
0
 /**
  * ondelete_callback
  * Delete related items in tl_comments
  * @param DataContainer $dc
  */
 public function deleteRelatedComments(DataContainer $dc)
 {
     // Return if there is no ID
     if (!$dc->activeRecord->id || Input::get('act') == 'copy') {
         return;
     }
     $objComments = $this->Database->prepare('SELECT * FROM tl_comments WHERE source = ? AND (owner = ? OR parent = ?)')->execute('tl_member', $dc->activeRecord->id, $dc->activeRecord->id);
     while ($objComments->next()) {
         $objDb = CommentsModel::findByPk($objComments->id);
         $objDb->delete();
         $this->log('DELETE FROM tl_comments WHERE id=' . $objComments->id, __METHOD__, TL_GENERAL);
     }
 }
Пример #2
0
 /**
  * Send out the new comment notifications
  *
  * @param mixed $varValue
  *
  * @return mixed
  */
 public function sendNotifications($varValue)
 {
     if ($varValue) {
         Comments::notifyCommentsSubscribers(CommentsModel::findByPk(Input::get('id')));
     }
     return $varValue;
 }
Пример #3
0
 /**
  * handle ajax requests
  */
 protected function handleAjax()
 {
     // delete socialmedia links
     if (\Input::get('act') == 'delSocialmediaLink' && \Input::post('type')) {
         if (FE_USER_LOGGED_IN) {
             $arrSocialmediaLinks = deserialize($this->loggedInUser->socialmediaLinks);
             if (array_search(\Input::post('type'), $arrSocialmediaLinks) !== false) {
                 $key = array_search(\Input::post('type'), $arrSocialmediaLinks);
                 unset($arrSocialmediaLinks[$key]);
             }
             $this->loggedInUser->socialmediaLinks = serialize(array_values($arrSocialmediaLinks));
             $this->loggedInUser->save();
             $this->log('A new version of tl_member ID ' . $this->loggedInUser->id . ' has been created', __METHOD__, TL_GENERAL);
         }
     }
     // toggle visibility (publish or unpublish)
     if (\Input::get('act') == 'toggleVisibility' && \Input::get('id')) {
         if (FE_USER_LOGGED_IN) {
             $objComment = \CommentsModel::findByPk(\Input::get('id'));
             if ($objComment !== NULL) {
                 if ($this->loggedInUser->id == $objComment->parent) {
                     $isPublished = $objComment->published ? 0 : 1;
                     $objComment->published = $isPublished;
                     $objComment->save();
                     $this->log('A new version of tl_comments ID ' . $objComment->id . ' has been created', __METHOD__, TL_GENERAL);
                     $strReturn = $isPublished == 0 ? 'invisible' : 'visible';
                     echo $strReturn;
                 }
             }
         }
     }
     exit;
 }