Пример #1
0
 public function onAfterDeleteTopic($target)
 {
     CFactory::load('libraries', 'activities');
     CActivityStream::remove('kunena.post', $target->id);
 }
Пример #2
0
 public function deleteEvent()
 {
     CFactory::load('libraries', 'activities');
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'defines.community.php';
     $event =& JTable::getInstance('Event', 'CTable');
     $data = JRequest::getVar('cid', '', 'post');
     $error = array();
     if (!is_array($data)) {
         $data[] = $data;
     }
     if (empty($data)) {
         JError::raiseError('500', JText::_('COM_COMMUNITY_INVALID_ID'));
     }
     foreach ($data as $id) {
         $event->load($id);
         $this->triggerEvents('onBeforeEventDelete', $event);
         $event->deleteAllMembers();
         $event->deleteWalls();
         $tmp = $event;
         if ($event->delete()) {
             if ($tmp->avatar != "components/com_community/assets/eventAvatar.png" && !empty($tmp->avatar)) {
                 $path = explode('/', $tmp->avatar);
                 $file = JPATH_ROOT . DS . $path[0] . DS . $path[1] . DS . $path[2] . DS . $path[3];
                 if (JFile::exists($file)) {
                     JFile::delete($file);
                 }
             }
             if ($tmp->thumb != "components/com_community/assets/event_thumb.png" && !empty($tmp->avatar)) {
                 $file = JPATH_ROOT . DS . CString::str_ireplace('/', DS, $tmp->thumb);
                 if (JFile::exists($file)) {
                     JFile::delete($file);
                 }
             }
             $this->triggerEvents('onAfterEventDelete', $tmp);
             CActivityStream::remove('events', $id);
             $error[] = false;
         } else {
             $error[] = true;
         }
     }
     $mainframe =& JFactory::getApplication();
     if (in_array(true, $error)) {
         $mainframe->redirect('index.php?option=com_community&view=events', JText::_('COM_COMMUNITY_EVENTS_REMOVING_ERROR'), 'error');
     } else {
         $mainframe->redirect('index.php?option=com_community&view=events', JText::_('COM_COMMUNITY_EVENTS_DELETED'));
     }
 }
Пример #3
0
 /**
  * Controller method to remove an album
  **/
 public function removealbum()
 {
     if ($this->blockUnregister()) {
         return;
     }
     // Check for request forgeries
     JRequest::checkToken() or jexit(JText::_('CC INVALID TOKEN'));
     // Get the album id.
     $my = CFactory::getUser();
     $id = JRequest::getInt('albumid', '');
     $task = JRequest::getCmd('currentTask', '');
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($id);
     if ($album->permanent == 1) {
         return;
     }
     /** HTGMOD **/
     $handler = $this->_getHandler($album);
     // Load libraries
     CFactory::load('models', 'photos');
     CFactory::load('libraries', 'activities');
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($id);
     CFactory::load('helpers', 'owner');
     if (!$handler->hasPermission($album->id)) {
         $this->blockUserAccess();
         return;
     }
     $model = CFactory::getModel('photos');
     CFactory::load('libraries', 'apps');
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] = $album;
     $url = $handler->getEditedAlbumURL($album->id);
     if ($album->delete()) {
         $appsLib->triggerEvent('onAfterAlbumDelete', $params);
         // @rule: remove from featured item if item is featured
         CFactory::load('libraries', 'featured');
         $featured = new CFeatured(FEATURED_ALBUMS);
         $featured->delete($album->id);
         //add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('album.remove');
         // Remove from activity stream
         CActivityStream::remove('photos', $id);
         $mainframe =& JFactory::getApplication();
         $task = !empty($task) ? '&task=' . $task : '';
         $message = JText::sprintf('CC ALBUM REMOVED', $album->name);
         $mainframe->redirect($url, $message);
     }
 }
Пример #4
0
 /**
  *  Ajax function to delete a event
  *
  * @param	$eventId	The specific event id to unpublish
  **/
 public function ajaxDeleteEvent($eventId, $step = 1)
 {
     $response = new JAXResponse();
     $filter = JFilterInput::getInstance();
     $eventId = $filter->clean($eventId, 'int');
     $step = $filter->clean($step, 'int');
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'owner');
     CFactory::load('models', 'events');
     $model = CFactory::getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     $event->load($eventId);
     $membersCount = $event->getMembersCount('accepted');
     $my = CFactory::getUser();
     $isMine = $my->id == $event->creator;
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     // only check for step 1 as the following steps will remove member, including event creator which will violate permission
     if (!$handler->manageable() && $step == 1) {
         $content = JText::_('COM_COMMUNITY_EVENTS_NOT_ALLOW_DELETE');
         $actions = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('COM_COMMUNITY_CANCEL') . '"/>';
         $response->addScriptCall('cWindowAddContent', $content, $actions);
         return $response->sendResponse();
     }
     $response->addScriptCall('cWindowResize', 160);
     $doneMessage = ' - <span class=\'success\'>' . JText::_('COM_COMMUNITY_DONE') . '</span><br />';
     $failedMessage = ' - <span class=\'failed\'>' . JText::_('COM_COMMUNITY_FAILED') . '</span><br />';
     switch ($step) {
         case 1:
             // Nothing gets deleted yet. Just show a messge to the next step
             if (empty($eventId)) {
                 $content = JText::_('COM_COMMUNITY_EVENTS_INVALID_ID_ERROR');
             } else {
                 $content = '<strong>' . JText::sprintf('COM_COMMUNITY_EVENTS_DELETING', $event->title) . '</strong><br/>';
                 $content .= JText::_('COM_COMMUNITY_EVENTS_DELETE_MEMBERS');
                 $response->addScriptCall('jax.call(\'community\', \'events,ajaxDeleteEvent\', \'' . $eventId . '\', 2 );');
                 $this->triggerEvents('onBeforeEventDelete', $event);
             }
             $response->addScriptCall('cWindowAddContent', $content);
             break;
         case 2:
             // Delete all event members
             if ($event->deleteAllMembers()) {
                 $content = $doneMessage;
             } else {
                 $content = $failedMessage;
             }
             $content .= JText::_('COM_COMMUNITY_EVENTS_DELETE_WALLS');
             $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
             $response->addScriptCall('jax.call(\'community\', \'events,ajaxDeleteEvent\', \'' . $eventId . '\', 3 );');
             break;
         case 3:
             // Delete all event wall
             if ($event->deleteWalls()) {
                 $content = $doneMessage;
             } else {
                 $content = $failedMessage;
             }
             $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
             $response->addScriptCall('jax.call(\'community\', \'events,ajaxDeleteEvent\', \'' . $eventId . '\', 4 );');
             break;
         case 4:
             // Delete event master record
             $eventData = $event;
             if ($event->delete()) {
                 // Delete featured event.
                 CFactory::load('libraries', 'featured');
                 $featured = new CFeatured(FEATURED_EVENTS);
                 $featured->delete($eventId);
                 jimport('joomla.filesystem.file');
                 if ($eventData->avatar != "components/com_community/assets/eventAvatar.png" && !empty($eventData->avatar)) {
                     $path = explode('/', $eventData->avatar);
                     $file = JPATH_ROOT . DS . $path[0] . DS . $path[1] . DS . $path[2] . DS . $path[3];
                     if (JFile::exists($file)) {
                         JFile::delete($file);
                     }
                 }
                 if ($eventData->thumb != "components/com_community/assets/event_thumb.png" && !empty($eventData->avatar)) {
                     //$path = explode('/', $eventData->avatar);
                     //$file = JPATH_ROOT . DS . $path[0] . DS . $path[1] . DS . $path[2] .DS . $path[3];
                     $file = JPATH_ROOT . DS . CString::str_ireplace('/', DS, $eventData->thumb);
                     if (JFile::exists($file)) {
                         JFile::delete($file);
                     }
                 }
                 $html = '<div class=\\"info\\" style=\\"display: none;\\">' . JText::_('COM_COMMUNITY_EVENTS_DELETED') . '</div>';
                 $response->addScriptCall('joms.jQuery("' . $html . '").prependTo("#community-wrap").fadeIn();');
                 $response->addScriptCall('joms.jQuery("#community-groups-wrap").fadeOut();');
                 $content = JText::_('COM_COMMUNITY_EVENTS_DELETED');
                 //trigger for onGroupDelete
                 $this->triggerEvents('onAfterEventDelete', $eventData);
                 // Remove from activity stream
                 CActivityStream::remove('events', $eventId);
                 $this->cacheClean(array(COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_EVENTS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
             } else {
                 $content = JText::_('COM_COMMUNITY_EVENTS_DELETING_ERROR');
             }
             $redirectURL = CRoute::_('index.php?option=com_community&view=events&task=myevents&userid=' . $my->id);
             $actions = '<input type="button" class="button" id="eventDeleteDone" onclick="cWindowHide(); window.location=\'' . $redirectURL . '\';" value="' . JText::_('COM_COMMUNITY_DONE_BUTTON') . '"/>';
             $response->addScriptCall('cWindowAddContent', $content, $actions);
             break;
         default:
             break;
     }
     return $response->sendResponse();
 }
Пример #5
0
 /**
  * Delete post message
  *
  * @param	response	An ajax Response object
  * @param	id			A unique identifier for the wall row
  *
  * returns	response
  */
 function ajaxRemoveWall($response, $id, $cache_id = "")
 {
     $my = CFactory::getUser();
     $wallModel = CFactory::getModel('wall');
     $wall = $wallModel->get($id);
     CError::assert($id, '', '!empty', __FILE__, __LINE__);
     CFactory::load('helpers', 'owner');
     // Make sure the current user actually has the correct permission
     // Only the original writer and the person the wall is meant for (and admin of course)
     // can delete the wall
     if ($my->id == $wall->post_by || $my->id == $wall->contentid || COwnerHelper::isCommunityAdmin()) {
         if ($wallModel->deletePost($id)) {
             // @rule: Remove the wall activity from the database as well
             CFactory::load('libraries', 'activities');
             CActivityStream::remove('walls', $id);
             //add user points
             if ($wall->post_by != 0) {
                 CFactory::load('libraries', 'userpoints');
                 CUserPoints::assignPoint('wall.remove', $wall->post_by);
             }
         } else {
             $html = JText::_('Error while removing wall. Line:' . __LINE__);
             $response->addAlert($html);
         }
         $cache =& JFactory::getCache('plgCommunityWalls');
         $cache->remove($cache_id);
         $cache =& JFactory::getCache('plgCommunityWalls_fullview');
         $cache->remove($cache_id);
     } else {
         $html = JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING');
         $response->addAlert($html);
     }
     return $response;
 }
Пример #6
0
 public function deleteBulletin()
 {
     $mainframe =& JFactory::getApplication();
     $my = CFactory::getUser();
     CFactory::load('libraries', 'activities');
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     $bulletinId = JRequest::getInt('bulletinid', '', 'POST');
     $groupid = JRequest::getInt('groupid', '', 'POST');
     if (empty($bulletinId) || empty($groupid)) {
         echo JText::_('COM_COMMUNITY_INVALID_ID');
         return;
     }
     CFactory::load('helpers', 'owner');
     CFactory::load('models', 'bulletins');
     $groupsModel = CFactory::getModel('groups');
     $bulletin =& JTable::getInstance('Bulletin', 'CTable');
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($groupid);
     if ($groupsModel->isAdmin($my->id, $group->id) || COwnerHelper::isCommunityAdmin()) {
         $bulletin->load($bulletinId);
         if ($bulletin->delete()) {
             //add user points
             CFactory::load('libraries', 'userpoints');
             CUserPoints::assignPoint('group.news.remove');
             CActivityStream::remove('groups.bulletin', $bulletinId);
             $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES, COMMUNITY_CACHE_TAG_GROUPS_DETAIL));
             $mainframe->redirect(CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupid, false), JText::_('COM_COMMUNITY_BULLETIN_REMOVED'));
         }
     } else {
         $mainframe->redirect(CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupid, false), JText::_('COM_COMMUNITY_GROUPS_DISCUSSION_DELETE_WARNING'));
     }
 }
Пример #7
0
 /**
  * Controller method to remove a video
  **/
 public function removevideo()
 {
     $videoId = JRequest::getVar('videoid', '', 'POST');
     $message = $this->deleteVideo($videoId);
     $mainframe = JFactory::getApplication();
     $url = CRoute::_('index.php?option=com_community&view=videos', false);
     if ($message) {
         // Remove from activity stream
         CFactory::load('libraries', 'activities');
         CActivityStream::remove('videos', $videoId);
         $mainframe->redirect($url, $message);
     } else {
         $message = JText::_('CC ERROR DELETING VIDEO');
         $mainframe->redirect($url, $message);
     }
 }
Пример #8
0
 /**
  * Delete an album
  * Set all photo within the album to have albumid = 0
  * Do not yet delete the photos, this could be very slow on an album that
  * has huge amount of photos
  */
 public function delete($pk = null)
 {
     //lets get all the photo info under the album
     $photoModel = CFactory::getModel('photos');
     $photos = $photoModel->getAllPhotos($this->id, $this->type);
     $db = JFactory::getDBO();
     $strSQL = 'UPDATE ' . $db->quoteName('#__community_photos') . ' SET ' . $db->quoteName('albumid') . '=' . $db->Quote(0) . ', ' . $db->quoteName('status') . ' = ' . $db->quote('temp') . ' WHERE ' . $db->quoteName('albumid') . '=' . $db->Quote($this->id);
     $db->setQuery($strSQL);
     $result = $db->query();
     // The whole local folder should be deleted, regardless of the storage type
     // BUT some old version of JomSocial might store other photo in the same
     // folder, we check in db first
     $strSQL = 'SELECT count(*) FROM ' . $db->quoteName('#__community_photos') . ' WHERE ' . $db->quoteName('image') . ' LIKE ' . $db->Quote('%' . dirname($this->path) . '%');
     $db->setQuery($strSQL);
     $result = $db->loadResult();
     if ($result == 0) {
         if (JFolder::exists(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id)) {
             JFolder::delete(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id);
         }
     }
     // We need to delete all activity stream related to this album
     CActivityStream::remove('photos', $this->id);
     //we need to delete all activity related to the photos inside the album as well
     if (isset($photos) && count($photos) > 0) {
         foreach ($photos as $photo) {
             CActivityStream::remove('photos', $photo->id);
         }
     }
     /* Delete album directory */
     $config = CFactory::getConfig();
     $dirPath = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/photos/' . $this->creator . '/' . $this->id;
     if (JFolder::exists($dirPath)) {
         JFolder::delete($dirPath);
     }
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $appsLib->triggerEvent('onAfterAlbumDelete', array($this));
     // @rule: remove from featured item if item is featured
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featured->delete($this->id);
     // if this is an avatar, we have to remove the avatar from the respective user
     if ($this->type == 'profile.avatar') {
         $user = CFactory::getUser($this->creator);
         $userModel = CFactory::getModel('User');
         $userModel->removeProfilePicture($user->id, 'avatar');
         $userModel->removeProfilePicture($user->id, 'thumb');
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('profile.avatar.upload', $user->id);
     } elseif ($this->type == 'event.avatar') {
         $eventTable = JTable::getInstance('Event', 'CTable');
         $eventTable->load($this->eventid);
         $eventTable->removeAvatar();
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('events.avatar.upload', $this->eventid);
     } elseif ($this->type == 'group.avatar') {
         $eventTable = JTable::getInstance('Group', 'CTable');
         $eventTable->load($this->groupid);
         $eventTable->removeAvatar();
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('groups.avatar.upload', $this->groupid);
     }
     //add user points
     CUserPoints::assignPoint('album.remove');
     // Remove from activity stream
     //CActivityStream::remove('photos', $this->id);
     // Remove from activity stream
     CActivityStream::remove('albums', $this->id);
     // Remove likes activity
     $likeModel = CFactory::getModel('like');
     $likeModel->removeLikes('album', $this->id);
     // Remove comment
     $wallModel = CFactory::getModel('wall');
     $wallModel->deletePostByType('albums', $this->id);
     return parent::delete();
 }
Пример #9
0
 /**
  *  Ajax function to delete a group
  *
  * @param	$groupId	The specific group id to unpublish
  **/
 public function ajaxDeleteGroup($groupId, $step = 1)
 {
     $response = new JAXResponse();
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'owner');
     CFactory::load('models', 'groups');
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($groupId);
     $groupModel = CFactory::getModel('groups');
     $membersCount = $groupModel->getMembersCount($groupId);
     $my = CFactory::getUser();
     $isMine = $my->id == $group->ownerid;
     if (!COwnerHelper::isCommunityAdmin() && !($isMine && $membersCount <= 1)) {
         $content = JText::_('CC NOT ALLOWED TO DELETE GROUP');
         $buttons = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('CC CANCEL') . '"/>';
         $response->addScriptCall('cWindowResize', 100);
         $response->addAssign('cWindowContent', 'innerHTML', $content);
         $response->addScriptCall('cWindowActions', $buttons);
     } else {
         $response->addScriptCall('cWindowResize', 160);
         $doneMessage = ' - <span class=\'success\'>' . JText::_('CC DONE') . '</span><br />';
         $failedMessage = ' - <span class=\'failed\'>' . JText::_('CC FAILED') . '</span><br />';
         switch ($step) {
             case 1:
                 // Nothing gets deleted yet. Just show a messge to the next step
                 if (empty($groupId)) {
                     $content = JText::_('CC INVALID GROUP ID');
                 } else {
                     $content = '<strong>' . JText::sprintf('CC DELETING GROUP', $group->name) . '</strong><br/>';
                     $content .= JText::_('CC DELETING GROUP BULLETIN');
                     $response->addScriptCall('jax.call(\'community\', \'groups,ajaxDeleteGroup\', \'' . $groupId . '\', 2);');
                     //trigger for onBeforeGroupDelete
                     $this->triggerGroupEvents('onBeforeGroupDelete', $group);
                 }
                 $response->addAssign('cWindowContent', 'innerHTML', $content);
                 break;
             case 2:
                 // Delete all group bulletins
                 if (CommunityModelGroups::deleteGroupBulletins($groupId)) {
                     $content = $doneMessage;
                 } else {
                     $content = $failedMessage;
                 }
                 $content .= JText::_('CC DELETING GROUP MEMBERS');
                 $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
                 $response->addScriptCall('jax.call(\'community\', \'groups,ajaxDeleteGroup\', \'' . $groupId . '\', 3);');
                 break;
             case 3:
                 // Delete all group members
                 if (CommunityModelGroups::deleteGroupMembers($groupId)) {
                     $content = $doneMessage;
                 } else {
                     $content = $failedMessage;
                 }
                 $content .= JText::_('CC DELETING GROUP WALLS');
                 $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
                 $response->addScriptCall('jax.call(\'community\', \'groups,ajaxDeleteGroup\', \'' . $groupId . '\', 4);');
                 break;
             case 4:
                 // Delete all group wall
                 if (CommunityModelGroups::deleteGroupWall($groupId)) {
                     $content = $doneMessage;
                 } else {
                     $content = $failedMessage;
                 }
                 $content .= JText::_('CC DELETING GROUP DISCUSSIONS');
                 $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
                 $response->addScriptCall('jax.call(\'community\', \'groups,ajaxDeleteGroup\', \'' . $groupId . '\', 5);');
                 break;
             case 5:
                 // Delete all group discussions
                 if (CommunityModelGroups::deleteGroupDiscussions($groupId)) {
                     $content = $doneMessage;
                 } else {
                     $content = $failedMessage;
                 }
                 $content .= JText::_('CC DELETING GROUP MEDIA');
                 $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
                 $response->addScriptCall('jax.call(\'community\', \'groups,ajaxDeleteGroup\', \'' . $groupId . '\', 6);');
                 break;
             case 6:
                 // Delete all group's media files
                 if (CommunityModelGroups::deleteGroupMedia($groupId)) {
                     $content = $doneMessage;
                 } else {
                     $content = $failedMessage;
                 }
                 $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
                 $response->addScriptCall('jax.call(\'community\', \'groups,ajaxDeleteGroup\', \'' . $groupId . '\', 7);');
                 break;
             case 7:
                 // Delete group
                 $group =& JTable::getInstance('Group', 'CTable');
                 $group->load($groupId);
                 $groupData = $group;
                 if ($group->delete($groupId)) {
                     CFactory::load('libraries', 'featured');
                     $featured = new CFeatured(FEATURED_GROUPS);
                     $featured->delete($groupId);
                     jimport('joomla.filesystem.file');
                     //@rule: Delete only thumbnail and avatars that exists for the specific group
                     if ($groupData->avatar != "components/com_community/assets/group.jpg" && !empty($groupData->avatar)) {
                         $path = explode('/', $groupData->avatar);
                         $file = JPATH_ROOT . DS . $path[0] . DS . $path[1] . DS . $path[2] . DS . $path[3];
                         if (JFile::exists($file)) {
                             JFile::delete($file);
                         }
                     }
                     if ($groupData->thumb != "components/com_community/assets/group_thumb.jpg" && !empty($groupData->thumb)) {
                         $path = explode('/', $groupData->thumb);
                         $file = JPATH_ROOT . DS . $path[0] . DS . $path[1] . DS . $path[2] . DS . $path[3];
                         if (JFile::exists($file)) {
                             JFile::delete($file);
                         }
                     }
                     $html = '<div class=\\"info\\" style=\\"display: none;\\">' . JText::_('CC GROUP DELETED') . '</div>';
                     $response->addScriptCall('joms.jQuery("' . $html . '").prependTo("#community-wrap").fadeIn();');
                     $response->addScriptCall('joms.jQuery("#community-groups-wrap").fadeOut();');
                     $content = JText::_('CC GROUP DELETED');
                     //trigger for onGroupDelete
                     $this->triggerGroupEvents('onAfterGroupDelete', $groupData);
                     // Remove from activity stream
                     CActivityStream::remove('groups', $groupId);
                 } else {
                     $content = JText::_('CC ERROR WHILE DELETING GROUP');
                 }
                 $redirect = CRoute::_(JURI::root() . 'index.php?option=com_community&view=groups');
                 $buttons = '<input type="button" class="button" id="groupDeleteDone" onclick="cWindowHide(); window.location=\'' . $redirect . '\';" value="' . JText::_('Done') . '"/>';
                 $response->addAssign('cWindowContent', 'innerHTML', $content);
                 $response->addScriptCall('cWindowActions', $buttons);
                 $response->addScriptCall('cWindowResize', 100);
                 break;
             default:
                 break;
         }
     }
     return $response->sendResponse();
 }
Пример #10
0
 /**
  * Delete an album
  * Set all photo within the album to have albumid = 0
  * Do not yet delete the photos, this could be very slow on an album that 
  * has huge amount of photos	 	 	 
  */
 public function delete()
 {
     $db =& JFactory::getDBO();
     $strSQL = 'UPDATE ' . $db->nameQuote('#__community_photos') . ' SET ' . $db->nameQuote('albumid') . '=' . $db->Quote(0) . ' WHERE ' . $db->nameQuote('albumid') . '=' . $db->Quote($this->id);
     $db->setQuery($strSQL);
     $result = $db->query();
     // The whole local folder should be deleted, regardless of the storage type
     // BUT some old version of JomSocial might store other photo in the same
     // folder, we check in db first
     $strSQL = 'SELECT count(*) FROM ' . $db->nameQuote('#__community_photos') . ' WHERE ' . $db->nameQuote('image') . ' LIKE ' . $db->Quote('%' . dirname($this->path) . '%');
     $db->setQuery($strSQL);
     $result = $db->loadResult();
     if ($result == 0) {
         JFolder::delete(JPATH_ROOT . DS . rtrim($this->path, '/') . DS . $this->id);
     }
     // We need to delete all activity stream related to this album
     CFactory::load('libraries', 'activities');
     CActivityStream::remove('photos', $this->id);
     return parent::delete();
 }
Пример #11
0
 /**
  * Controller method responsible to display the edit task.
  *
  * @return    none
  * */
 public function edit()
 {
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $jinput = JFactory::getApplication()->input;
     $viewName = $jinput->get('view', $this->getName(), 'String');
     $view = $this->getView($viewName, '', $viewType);
     $eventId = $jinput->get('eventid', 0, 'Int');
     $event = JTable::getInstance('Event', 'CTable');
     $event->load($eventId);
     if (empty($event->id)) {
         return JError::raiseWarning(404, JText::_('COM_COMMUNITY_EVENTS_NOT_AVAILABLE_ERROR'));
     }
     $my = CFactory::getUser();
     $handler = CEventHelper::getHandler($event);
     if (!$handler->manageable()) {
         echo JText::_('COM_COMMUNITY_RESTRICTED_ACCESS');
         return;
     }
     if ($jinput->getMethod() == 'POST') {
         $eid = $this->save($event);
         if ($eid !== false) {
             $mainframe = JFactory::getApplication();
             $event->load($eventId);
             //trigger for onGroupCreate
             $this->triggerEvents('onEventUpdate', $event);
             $action_str = 'event.update';
             $act = new stdClass();
             $act->cmd = $action_str;
             $act->actor = $my->id;
             $act->target = 0;
             $act->title = '';
             //JText::sprintf('COM_COMMUNITY_GROUPS_GROUP_UPDATED' , '{group_url}' , $group->name );
             $act->content = '';
             $act->app = 'events.update';
             $act->cid = $event->id;
             $act->eventid = $event->id;
             $act->event_access = $event->permission;
             $act->groupid = $event->type == 'group' ? $event->contentid : 0;
             $params = new CParameter('');
             $params->set('action', $action_str);
             $params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
             // Add activity logging. Delete old ones
             CActivityStream::remove($act->app, $act->cid);
             CActivityStream::add($act, $params->toString());
             // add user points
             CUserPoints::assignPoint('events.update');
             $mainframe->redirect($handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false), JText::sprintf('COM_COMMUNITY_EVENTS_UPDATE_NOTICE', $event->title));
             return;
         }
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_EVENTS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
     echo $view->get(__FUNCTION__, $event);
 }
Пример #12
0
 public function removeProfileCover($id)
 {
     $db = $this->getDBO();
     // Test if the record exists.
     $query = 'SELECT ' . $db->quoteName('cover') . ' FROM ' . $db->quoteName('#__community_users') . 'WHERE ' . $db->quoteName('userid') . '=' . $db->Quote($id);
     $db->setQuery($query);
     $oldFile = $db->loadResult();
     if (JFile::exists($oldFile)) {
         $query = "SELECT " . $db->quoteName('id') . " FROM " . $db->quoteName('#__community_photos') . " WHERE " . $db->quoteName('image') . " = " . $db->quote($oldFile);
         $db->setQuery($query);
         $pid = $db->loadResult();
         $photoTable = JTable::getInstance('Photo', 'CTable');
         $photoTable->load($pid);
         $photoTable->delete();
         CActivityStream::remove('cover.upload', $pid);
     }
     $query = 'UPDATE ' . $db->quoteName('#__community_users') . ' ' . 'SET ' . $db->quoteName('cover') . '=' . $db->Quote('') . ' ' . 'WHERE ' . $db->quoteName('userid') . '=' . $db->Quote($id);
     $db->setQuery($query);
     $db->query($query);
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     return true;
 }
Пример #13
0
 /**
  * Delete an album
  * Set all photo within the album to have albumid = 0
  * Do not yet delete the photos, this could be very slow on an album that
  * has huge amount of photos
  */
 public function delete($pk = null)
 {
     //lets get all the photo info under the album
     $photoModel = CFactory::getModel('photos');
     $photos = $photoModel->getAllPhotos($this->id, $this->type);
     $db = JFactory::getDBO();
     $strSQL = 'UPDATE ' . $db->quoteName('#__community_photos') . ' SET ' . $db->quoteName('albumid') . '=' . $db->Quote(0) . ', ' . $db->quoteName('status') . ' = ' . $db->quote('temp') . ' WHERE ' . $db->quoteName('albumid') . '=' . $db->Quote($this->id);
     $db->setQuery($strSQL);
     $result = $db->query();
     // The whole local folder should be deleted, regardless of the storage type
     // BUT some old version of JomSocial might store other photo in the same
     // folder, we check in db first
     $strSQL = 'SELECT count(*) FROM ' . $db->quoteName('#__community_photos') . ' WHERE ' . $db->quoteName('image') . ' LIKE ' . $db->Quote('%' . dirname($this->path) . '%');
     $db->setQuery($strSQL);
     $result = $db->loadResult();
     if ($result == 0) {
         if (JFolder::exists(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id)) {
             JFolder::delete(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id);
         }
     }
     // We need to delete all activity stream related to this album
     CActivityStream::remove('photos', $this->id);
     //we need to delete all activity related to the photos inside the album as well
     if (isset($photos) && count($photos) > 0) {
         foreach ($photos as $photo) {
             CActivityStream::remove('photos', $photo->id);
         }
     }
     return parent::delete();
 }
Пример #14
0
 public static function removeJomsocialActivity($blog)
 {
     $config = EasyBlogHelper::getConfig();
     if (!$config->get('integrations_jomsocial_unpublish_remove_activity')) {
         return false;
     }
     $jsCoreFile = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
     $lang = JFactory::getLanguage();
     $lang->load('com_easyblog', JPATH_ROOT);
     if (!JFile::exists($jsCoreFile)) {
         return false;
     }
     require_once $jsCoreFile;
     CFactory::load('libraries', 'activities');
     CActivityStream::remove('easyblog', $blog->id);
 }
Пример #15
0
 public function ajaxRemoveVideo($id)
 {
     $filter = JFilterInput::getInstance();
     $id = $filter->clean($id, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $my = CFactory::getUser();
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($id);
     $message = $this->deleteVideo($video->id, false);
     $json = array();
     if ($message != false) {
         CActivityStream::remove('videos', $video->id);
         $json['success'] = true;
         $json['message'] = $message;
     } else {
         $message = JText::_('COM_COMMUNITY_VIDEOS_DELETING_VIDEO_ERROR');
         $json['error'] = $message;
     }
     die(json_encode($json));
 }
Пример #16
0
 public function onAfterDeleteTopic($target)
 {
     CFactory::load('libraries', 'activities');
     CActivityStream::remove('kunena.thread.post', $target->id);
     // TODO: Need get replied id
     CActivityStream::remove('kunena.thread.replied', $target->id);
 }
Пример #17
0
 /**
  * Removes a stream from JomSocial
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function removePostStream(EasyBlogPost $post)
 {
     if (!$this->exists()) {
         return false;
     }
     if (!$this->config->get('integrations_jomsocial_unpublish_remove_activity')) {
         return false;
     }
     CFactory::load('libraries', 'activities');
     CActivityStream::remove('easyblog', $post->id);
 }
Пример #18
0
 /**
  * Delete the photo, the original and the actual resized photos and thumbnails
  */
 public function delete($pk = null)
 {
     $storage = CStorage::getStorage($this->storage);
     $storage->delete($this->image);
     $storage->delete($this->thumbnail);
     /* We did store original than now time to remove it */
     if (!empty($this->original)) {
         /* Original do not sync with 3rd storage than we don't need to use $storage->delete; even it would be same */
         if (JFile::exists(JPATH_ROOT . '/' . $this->original)) {
             JFile::delete(JPATH_ROOT . '/' . $this->original);
         }
         $originalDir = dirname(JPATH_ROOT . '/' . $this->original);
         $files = JFolder::files($originalDir);
         /* If the original path is empty, we can delete it too */
         if (empty($files)) {
             JFolder::delete($originalDir);
         }
     }
     // if the photo is the album cover, set the album cover as default 0
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($this->albumid);
     $album->set('photoid', 0);
     $album->store();
     // delete the tags
     CFactory::load('libraries', 'phototagging');
     $phototagging = new CPhotoTagging();
     $phototagging->removeTagByPhoto($this->id);
     // delete the activities
     CActivities::remove('photos', $this->id);
     //Remove photo from activity stream
     CActivityStream::remove('photo.like', $this->id);
     // delete the comments
     $wall = CFactory::getModel('wall');
     $wall->deleteAllChildPosts($this->id, 'photos');
     /* And now finally we do delete this photo in database */
     /* return parent::delete(); */
     /**
      * @since 3.2
      * We do not delete database record for now. Leave it for cron !
      * @todo Considering local files should be deleted this time or not ?
      */
     $this->published = 0;
     $this->status = 'delete';
     $this->store();
 }
Пример #19
0
 public function delete()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $model = $this->getModel('Videos', 'CommunityAdminModel');
     $id = $jinput->post->get('cid', '', 'array');
     $errors = false;
     $message = JText::_('Videos has ben deleted');
     if (empty($id)) {
         JError::raiseError('500', JText::_('COM_COMMUNITY_INVALID_ID'));
     }
     for ($i = 0; $i < count($id); $i++) {
         if (!$model->delete($id[$i])) {
             $errors = true;
         } else {
             // delete the stream
             CActivityStream::remove('videos', $id[$i]);
             CActivityStream::remove('videos.linking', $id[$i]);
         }
     }
     if ($errors) {
         $message = JText::_('Error deleting video');
     }
     $mainframe->redirect('index.php?option=com_community&view=videos', $message, 'message');
 }
Пример #20
0
 /**
  *
  * @param type $photoId
  * @param type $action
  * @return type
  */
 public function ajaxRemovePhoto($photoId, $action = '')
 {
     /* Cleanup input photoId */
     $filter = JFilterInput::getInstance();
     $photoId = $filter->clean($photoId, 'int');
     /* Permission checking: Only registered user can do */
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $model = CFactory::getModel('photos');
     $my = CFactory::getUser();
     /* Get CTablePhoto object */
     $photo = $model->getPhoto($photoId);
     /* Get CTableAlbum object */
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($photo->albumid);
     // add user points
     if ($photo->creator == $my->id) {
         CUserPoints::assignPoint('photo.remove');
     }
     /* Get handler to process */
     $handler = $this->_getHandler($album);
     /* Permission checking */
     if (!$handler->hasPermission($album->id)) {
         $json = array('error' => JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'));
         die(json_encode($json));
     }
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] = $photo;
     $appsLib->triggerEvent('onBeforePhotoDelete', $params);
     $photo->delete();
     $appsLib->triggerEvent('onAfterPhotoDelete', $params);
     $photoCount = count($model->getAllPhotos($photo->albumid));
     if (strpos($album->type, 'Cover') !== false) {
         CActivityStream::remove('cover.upload', $photo->id);
     }
     //Remove Photo related Comment
     CActivities::remove('photos.comment', $photo->id);
     //add user points
     CUserPoints::assignPoint('photo.remove');
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_ACTIVITIES));
     $json = array('success' => true);
     die(json_encode($json));
 }
Пример #21
0
 /**
  *  Ajax function to delete a event
  *
  * @param	$eventId	The specific event id to unpublish
  **/
 public function ajaxDeleteEvent($eventId, $step = 1)
 {
     $response = new JAXResponse();
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'owner');
     CFactory::load('models', 'events');
     $model = CFactory::getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     $event->load($eventId);
     $membersCount = $event->getMembersCount('accepted');
     $my = CFactory::getUser();
     $isMine = $my->id == $event->creator;
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     if (!$handler->manageable()) {
         $content = JText::_('CC NOT ALLOWED TO DELETE EVENT');
         $buttons = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('CC CANCEL') . '"/>';
         $response->addScriptCall('cWindowResize', 100);
         $response->addAssign('cWindowContent', 'innerHTML', $content);
         $response->addScriptCall('cWindowActions', $buttons);
         return $response->sendResponse();
     }
     // @rule: Do not allow event admin to delete event if there is less than 2 members
     if ($membersCount <= 1 && !COwnerHelper::isCommunityAdmin()) {
         $content = JText::_('CC NOT ALLOWED TO DELETE EVENT BECAUSE MEMBERS CRITERIA DOES NOT MATCH');
         $buttons = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('CC CANCEL') . '"/>';
         $response->addScriptCall('cWindowResize', 100);
         $response->addAssign('cWindowContent', 'innerHTML', $content);
         $response->addScriptCall('cWindowActions', $buttons);
         return $response->sendResponse();
     }
     $response->addScriptCall('cWindowResize', 160);
     $doneMessage = ' - <span class=\'success\'>' . JText::_('CC DONE') . '</span><br />';
     $failedMessage = ' - <span class=\'failed\'>' . JText::_('CC FAILED') . '</span><br />';
     switch ($step) {
         case 1:
             // Nothing gets deleted yet. Just show a messge to the next step
             if (empty($eventId)) {
                 $content = JText::_('CC INVALID EVENT ID');
             } else {
                 $content = '<strong>' . JText::sprintf('CC DELETING EVENT', $event->title) . '</strong><br/>';
                 $content .= JText::_('CC DELETING EVENT MEMBERS');
                 $response->addScriptCall('jax.call(\'community\', \'events,ajaxDeleteEvent\', \'' . $eventId . '\', 2 );');
                 $this->triggerEvents('onBeforeEventDelete', $event);
             }
             $response->addAssign('cWindowContent', 'innerHTML', $content);
             break;
         case 2:
             // Delete all event members
             if ($event->deleteAllMembers()) {
                 $content = $doneMessage;
             } else {
                 $content = $failedMessage;
             }
             $content .= JText::_('CC DELETING EVENT WALLS');
             $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
             $response->addScriptCall('jax.call(\'community\', \'events,ajaxDeleteEvent\', \'' . $eventId . '\', 3 );');
             break;
         case 3:
             // Delete all event wall
             if ($event->deleteWalls()) {
                 $content = $doneMessage;
             } else {
                 $content = $failedMessage;
             }
             $response->addScriptCall('joms.jQuery("#cWindowContent").append("' . $content . '");');
             $response->addScriptCall('jax.call(\'community\', \'events,ajaxDeleteEvent\', \'' . $eventId . '\', 4 );');
             break;
         case 4:
             // Delete event master record
             $eventData = $event;
             if ($event->delete()) {
                 jimport('joomla.filesystem.file');
                 if ($eventData->avatar != "components/com_community/assets/eventAvatar.png" && !empty($eventData->avatar)) {
                     $path = explode('/', $eventData->avatar);
                     $file = JPATH_ROOT . DS . $path[0] . DS . $path[1] . DS . $path[2] . DS . $path[3];
                     if (JFile::exists($file)) {
                         JFile::delete($file);
                     }
                 }
                 if ($eventData->thumb != "components/com_community/assets/event_thumb.png" && !empty($eventData->avatar)) {
                     //$path = explode('/', $eventData->avatar);
                     //$file = JPATH_ROOT . DS . $path[0] . DS . $path[1] . DS . $path[2] .DS . $path[3];
                     $file = JPATH_ROOT . DS . JString::str_ireplace('/', DS, $eventData->thumb);
                     if (JFile::exists($file)) {
                         JFile::delete($file);
                     }
                 }
                 $html = '<div class=\\"info\\" style=\\"display: none;\\">' . JText::_('CC EVENT DELETED') . '</div>';
                 $response->addScriptCall('joms.jQuery("' . $html . '").prependTo("#community-wrap").fadeIn();');
                 $response->addScriptCall('joms.jQuery("#community-groups-wrap").fadeOut();');
                 $content = JText::_('CC EVENT DELETED');
                 //trigger for onGroupDelete
                 $this->triggerEvents('onAfterEventDelete', $eventData);
                 // Remove from activity stream
                 CActivityStream::remove('events', $eventId);
             } else {
                 $content = JText::_('CC ERROR WHILE DELETING EVENT');
             }
             $redirectURL = CRoute::_('index.php?option=com_community&view=events&task=myevents&userid=' . $my->id);
             $buttons = '<input type="button" class="button" id="eventDeleteDone" onclick="cWindowHide(); window.location=\'' . $redirectURL . '\';" value="' . JText::_('CC BUTTON DONE') . '"/>';
             $response->addAssign('cWindowContent', 'innerHTML', $content);
             $response->addScriptCall('cWindowActions', $buttons);
             $response->addScriptCall('cWindowResize', 100);
             break;
         default:
             break;
     }
     return $response->sendResponse();
 }