예제 #1
0
 public function ajaxRemoveWall($wallId)
 {
     require_once JPATH_COMPONENT . '/libraries/activities.php';
     $filter = JFilterInput::getInstance();
     $wallId = $filter->clean($wallId, 'int');
     //CFactory::load( 'helpers' , 'owner' );
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     // Only allow wall removal by admin or owner of the video.
     $response = new JAXResponse();
     $json = array();
     $wallsModel = $this->getModel('wall');
     $wall = $wallsModel->get($wallId);
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($wall->contentid);
     $my = CFactory::getUser();
     if (COwnerHelper::isCommunityAdmin() || $my->id == $video->creator) {
         if ($wallsModel->deletePost($wallId)) {
             // Remove activity wall.
             CActivities::removeWallActivities(array('app' => 'videos', 'cid' => $wall->contentid, 'createdAfter' => $wall->date), $wallId);
             if ($wall->post_by != 0) {
                 //CFactory::load( 'libraries' , 'userpoints' );
                 CUserPoints::assignPoint('wall.remove', $wall->post_by);
             }
         } else {
             $json['error'] = JText::_('COM_COMMUNITY_GROUPS_REMOVE_WALL_ERROR');
         }
     } else {
         $json['error'] = JText::_('COM_COMMUNITY_GROUPS_REMOVE_WALL_ERROR');
     }
     if (!$json['error']) {
         $json['success'] = true;
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     die(json_encode($json));
 }
예제 #2
0
파일: photos.php 프로젝트: Jougito/DynWeb
 public function ajaxAlbumRemoveWall($wallId)
 {
     require_once JPATH_COMPONENT . '/libraries/activities.php';
     $filter = JFilterInput::getInstance();
     $wallId = $filter->clean($wallId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $response = new JAXResponse();
     $json = array();
     $wallsModel = $this->getModel('wall');
     $wall = $wallsModel->get($wallId);
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($wall->contentid);
     $my = CFactory::getUser();
     if ($my->id == $album->creator || COwnerHelper::isCommunityAdmin()) {
         if (!$wallsModel->deletePost($wallId)) {
             $json['error'] = JText::_('COM_COMMUNITY_GROUPS_REMOVE_WALL_ERROR');
         } else {
             CActivities::removeWallActivities(array('app' => 'albums', 'cid' => $wall->contentid, 'createdAfter' => $wall->date), $wallId);
         }
     } else {
         $json['error'] = JText::_('COM_COMMUNITY_GROUPS_REMOVE_WALL_ERROR');
     }
     if (!$json['error']) {
         $json['success'] = true;
     }
     die(json_encode($json));
 }
예제 #3
0
 /**
  * Ajax function to remove a reply from the discussions
  *
  * @params $discussId	An string that determines the discussion id
  **/
 public function ajaxRemoveReply($wallId)
 {
     require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'activities.php';
     $filter = JFilterInput::getInstance();
     $wallId = $filter->clean($wallId, 'int');
     CError::assert($wallId, '', '!empty', __FILE__, __LINE__);
     $response = new JAXResponse();
     //@rule: Check if user is really allowed to remove the current wall
     $my = CFactory::getUser();
     $model =& $this->getModel('wall');
     $wall = $model->get($wallId);
     CFactory::load('models', 'discussions');
     $discussion =& JTable::getInstance('Discussion', 'CTable');
     $discussion->load($wall->contentid);
     CFactory::load('helpers', 'owner');
     if (!$my->authorise('community.delete', 'groups.discussion.' . $discussion->groupid)) {
         $errorMsg = $my->authoriseErrorMsg();
         if ($errorMsg == 'blockUnregister') {
             return $this->ajaxBlockUnregister();
         } else {
             $response->addScriptCall('alert', $errorMsg);
         }
     } else {
         if (!$model->deletePost($wallId)) {
             $response->addAlert(JText::_('COM_COMMUNITY_GROUPS_REMOVE_WALL_ERROR'));
         } else {
             // Update activity.
             CActivities::removeWallActivities(array('app' => 'groups.discussion.reply', 'cid' => $wall->contentid, 'createdAfter' => $wall->date), $wallId);
             //add user points
             if ($wall->post_by != 0) {
                 CFactory::load('libraries', 'userpoints');
                 CUserPoints::assignPoint('wall.remove', $wall->post_by);
             }
         }
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL));
     return $response->sendResponse();
 }