Пример #1
0
 /**
  * Delete the discussion
  * @param  [type] $oid [description]
  * @return [type]
  */
 public function delete($oid = null)
 {
     // Delete the stream related to the discussion replies
     CActivities::remove('groups.discussion.reply', $this->id);
     $result = parent::delete($oid);
     if ($result) {
         $this->_updateGroupStats();
     }
     return $result;
 }
Пример #2
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));
 }
Пример #3
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();
 }
Пример #4
0
 /**
  * Delete the photo, the original and the actual resized photos and thumbnails
  */
 public function delete()
 {
     CFactory::load('libraries', 'storage');
     $storage = CStorage::getStorage($this->storage);
     $storage->delete($this->image);
     $storage->delete($this->thumbnail);
     JFile::delete(JPATH_ROOT . DS . $this->original);
     // If the original path is empty, we can delete it too
     $files = JFolder::files(dirname(JPATH_ROOT . DS . $this->original));
     if (empty($files)) {
         JFolder::delete(dirname(JPATH_ROOT . DS . $this->original));
     }
     // 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');
     CPhotoTagging::removeTagByPhoto($this->id);
     // delete the activities
     CFactory::load('libraries', 'activities');
     CActivities::remove('photos', $this->id);
     // delete the comments
     $wall = CFactory::getModel('wall');
     $wall->deleteAllChildPosts($this->id, 'photos');
     return parent::delete();
 }