/**
  * Overrides xPDOObject::remove to fire modX-specific events
  *
  * {@inheritDoc}
  */
 public function remove(array $ancestors = array())
 {
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnUserGroupBeforeRemove', array('usergroup' => &$this, 'ancestors' => $ancestors));
     }
     $removed = parent::remove($ancestors);
     // delete ACLs for this group
     $targets = explode(',', $this->xpdo->getOption('principal_targets', null, 'modAccessContext,modAccessResourceGroup,modAccessCategory'));
     array_walk($targets, 'trim');
     foreach ($targets as $target) {
         $fields = $this->xpdo->getFields($target);
         if (array_key_exists('principal_class', $fields) && array_key_exists('principal', $fields)) {
             $tablename = $this->xpdo->getTableName($target);
             $principal_class_field = $this->xpdo->escape('principal_class');
             $principal_field = $this->xpdo->escape('principal');
             if (!empty($tablename)) {
                 $this->xpdo->query("DELETE FROM {$tablename} WHERE {$principal_class_field} = 'modUserGroup' AND {$principal_field} = {$this->_fields['id']}");
             }
         }
     }
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnUserGroupRemove', array('usergroup' => &$this, 'ancestors' => $ancestors));
     }
     return $removed;
 }
 /** {@inheritdoc} */
 public function remove(array $ancestors = array())
 {
     $id = $this->get('id');
     $table = $this->xpdo->getTableName('msDeliveryMember');
     $sql = "DELETE FROM {$table} WHERE `delivery_id` = '{$id}';";
     $this->xpdo->exec($sql);
     return parent::remove();
 }
 public function remove(array $ancestors = array())
 {
     $removed = parent::remove($ancestors);
     if ($removed && !$this->getOption(xPDO::OPT_SETUP)) {
         $this->xpdo->call('modExtensionPackage', 'clearCache', array(&$this->xpdo));
     }
     return $removed;
 }
 /**
  * {@inheritdoc}
  *
  */
 public function remove(array $ancestors = array())
 {
     $id = $this->get('id');
     $sql = 'DELETE FROM ' . $this->xpdo->getTableName('msProductOption') . ' WHERE `product_id` = ' . $id . ';';
     $stmt = $this->xpdo->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     return parent::remove();
 }
 public function remove(array $ancestors = array())
 {
     $remove = parent::remove($ancestors);
     /** @var msdCouponGroup $group */
     if ($group = $this->getOne('Group')) {
         $group->updateCounters();
     }
     return $remove;
 }
 /**
  * Overrides the xPDOObject::remove method to remove the physical file for
  * the attachment
  *
  * @param array $ancestors
  * @return boolean
  */
 public function remove(array $ancestors = array())
 {
     $filename = $this->get('filename');
     if (!empty($filename)) {
         $filename = $this->getPath();
         if (!@unlink($filename)) {
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, '[Discuss] An error occurred while trying to remove the attachment file at: ' . $filename);
         }
     }
     return parent::remove($ancestors);
 }
 /**
  * @param array $ancestors
  * @return bool
  */
 public function remove(array $ancestors = array())
 {
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('MlmSystemOnLogBeforeRemove', array('log' => &$this, 'ancestors' => $ancestors));
     }
     $removed = parent::remove($ancestors);
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('MlmSystemOnLogRemove', array('log' => &$this, 'ancestors' => $ancestors));
     }
     return $removed;
 }
 /**
  * Overrides xPDOObject::remove to fire modX-specific events
  *
  * {@inheritDoc}
  */
 public function remove(array $ancestors = array())
 {
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnUserGroupBeforeRemove', array('usergroup' => &$this, 'ancestors' => $ancestors));
     }
     $removed = parent::remove($ancestors);
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnUserGroupRemove', array('usergroup' => &$this, 'ancestors' => $ancestors));
     }
     return $removed;
 }
Beispiel #9
0
 public function remove(array $ancestors = array())
 {
     $c = $this->xpdo->newQuery('galItem');
     $c->innerJoin('galAlbumItem', 'AlbumItems');
     $c->where(array('AlbumItems.album' => $this->get('id')));
     $items = $this->xpdo->getCollection('galItem', $c);
     $removed = parent::remove($ancestors);
     if ($removed) {
         foreach ($items as $item) {
             $count = $this->xpdo->getCount('galAlbumItem', array('item' => $item->get('id'), 'album:!=' => $this->get('id')));
             if ($count <= 0) {
                 $item->remove();
             }
         }
     }
     return $removed;
 }
 /**
  * Override xPDOObject::remove() to revert to the default dashboard any user groups using this Dashboard
  *
  * @see xPDOObject::remove()
  * @param array $ancestors
  * @return boolean
  */
 public function remove(array $ancestors = array())
 {
     $dashboardId = $this->get('id');
     $removed = parent::remove($ancestors);
     if ($removed) {
         $defaultDashboard = modDashboard::getDefaultDashboard($this->xpdo);
         if (empty($defaultDashboard)) {
             /** @var modDashboard $defaultDashboard */
             $defaultDashboard = $this->xpdo->newObject('modDashboard');
             $defaultDashboard->set('id', 0);
         }
         $userGroups = $this->xpdo->getCollection('modUserGroup', array('dashboard' => $dashboardId));
         /** @var modUserGroup $userGroup */
         foreach ($userGroups as $userGroup) {
             $userGroup->set('dashboard', $defaultDashboard->get('id'));
             $userGroup->save();
         }
     }
     return $removed;
 }
 public function remove(array $ancestors = array())
 {
     $ok = parent::remove($ancestors);
     if ($ok) {
         if ($thread = $this->Thread) {
             switch ($this->vote_direction) {
                 case '1':
                     $thread->positive_votes = $thread->positive_votes - 1;
                     break;
                 case '-1':
                     $thread->negative_votes = $thread->negative_votes - 1;
                     break;
                 default:
                     $thread->neutral_votes = $thread->neutral_votes - 1;
             }
             $thread->rating = $thread->rating - $this->vote_value;
             $thread->save();
         }
     }
     return $ok;
 }
    /**
     * Overrides xPDOObject::remove to fire modX-specific events.
     *
     * {@inheritDoc}
     */
    public function remove(array $ancestors = array()) {
        if ($this->xpdo instanceof modX) {
            $this->xpdo->invokeEvent('OnPropertySetBeforeRemove',array(
                'propertySet' => &$this,
                'ancestors' => $ancestors,
            ));
        }

        $removed = parent :: remove($ancestors);

        if ($removed && $this->xpdo instanceof modX) {
            $this->xpdo->invokeEvent('OnPropertySetRemove',array(
                'propertySet' => &$this,
                'ancestors' => $ancestors,
            ));
        }
        return $removed;
    }
 /**
  * @param array $ancestors
  *
  * @return bool
  */
 public function remove(array $ancestors = array())
 {
     $filename = $this->get('path') . $this->get('file');
     if ($this->prepareSource()) {
         $this->mediaSource->removeObject($filename);
         if (!empty($this->mediaSource->errors['file'])) {
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, '[Uploadify] Could not remove file at "' . $filename . '": ' . $this->mediaSource->errors['file']);
         }
     }
     $children = $this->xpdo->getIterator('uFile', array('parent' => $this->get('id')));
     /** @var uFile $child */
     foreach ($children as $child) {
         $child->remove();
     }
     return parent::remove($ancestors);
 }
Beispiel #14
0
 /**
  * Overrides xPDOObject::remove to handle closure tables, post counts, fix
  * the forum activity and user profile counts.
  *
  * @param array $ancestors
  * @param boolean $doBoardMoveChecks
  * @param boolean $moveToSpam
  * @return boolean
  */
 public function remove(array $ancestors = array(), $doBoardMoveChecks = false, $moveToSpam = false)
 {
     $removed = false;
     $moved = false;
     $canRemove = $this->xpdo->invokeEvent('OnDiscussPostBeforeRemove', array('post' => &$this, 'doBoardMoveChecks' => $doBoardMoveChecks, 'moveToSpam' => $moveToSpam));
     if (!empty($canRemove)) {
         return false;
     }
     /** @var disUser $author */
     $author = $this->getOne('Author');
     /** @var disThread $thread */
     $thread = $this->xpdo->getObject('disThread', array('id' => $this->get('thread')));
     /** @var disBoard $board */
     $board = $this->xpdo->getObject('disBoard', array('id' => $this->get('board')));
     $isPrivateMessage = !$thread || $thread->get('private');
     /* first check to see if moving to spam/trash */
     if (!empty($doBoardMoveChecks) && !$isPrivateMessage && !empty($board)) {
         $isModerator = $board->isModerator($this->xpdo->discuss->user->get('id'));
         $isAdmin = $this->xpdo->discuss->user->isAdmin();
         if ($isAdmin || $isModerator || $this->xpdo->discuss->user->get('id') == $this->get('author')) {
             /* move to spambox/recyclebin */
             $spamBoard = $this->xpdo->getOption('discuss.spam_bucket_board', null, false);
             if ($moveToSpam && !empty($spamBoard) && $this->get('board') != $spamBoard) {
                 $removed = $this->move($spamBoard);
                 $moved = true;
             } else {
                 $trashBoard = $this->xpdo->getOption('discuss.recycle_bin_board', null, false);
                 if (!empty($trashBoard) && $this->get('board') != $trashBoard) {
                     $removed = $this->move($trashBoard);
                     $moved = true;
                 }
             }
         }
     }
     if (!$removed) {
         $removed = parent::remove($ancestors);
     }
     if ($removed) {
         $parent = $this->get('parent');
         if (empty($parent)) {
             /* get oldest post and make it the new root post for the thread */
             $c = $this->xpdo->newQuery('disPost');
             $c->where(array('id:!=' => $this->get('id'), 'board' => $this->get('board'), 'thread' => $this->get('thread')));
             $c->sortby($this->xpdo->escape('createdon'), 'ASC');
             $c->limit(1);
             /* @var disPost $oldestPost */
             $oldestPost = $this->xpdo->getObject('disPost', $c);
             if ($oldestPost) {
                 $oldestPost->set('parent', 0);
                 if ($oldestPost->save()) {
                     $parent = $oldestPost->get('id');
                     $thread->set('post_first', $oldestPost->get('id'));
                     $thread->save();
                 }
             }
         }
         /* fix child posts' parent */
         foreach ($this->getMany('Children') as $child) {
             /* @var disPost $child */
             $child->set('parent', $parent);
             $child->save();
         }
         /* decrease profile posts */
         if ($author && !$isPrivateMessage) {
             $author->set('posts', $author->get('posts') - 1);
             $author->save();
         }
         /* fix board last post */
         if ($board && !$isPrivateMessage) {
             $c = $this->xpdo->newQuery('disPost');
             $c->where(array('id:!=' => $this->get('id'), 'board' => $board->get('id')));
             $c->sortby('createdon', 'DESC');
             $c->limit(1);
             /** @var disPost $latestPost */
             $latestPost = $this->xpdo->getObject('disPost', $c);
             if ($latestPost) {
                 $board->set('last_post', $latestPost->get('id'));
             } else {
                 $board->set('last_post', 0);
             }
             /* fix board total post/replies/topics counts */
             $board->set('total_posts', $board->get('total_posts') - 1);
             if ($parent == 0) {
                 $board->set('num_topics', $board->get('num_topics') - 1);
             } else {
                 $board->set('num_replies', $board->get('num_replies') - 1);
             }
             $board->save();
         }
         /* fix thread posts/data */
         if ($thread) {
             $thread->set('replies', $thread->get('replies') - 1);
             $c = $this->xpdo->newQuery('disPost');
             $c->where(array('id:!=' => $this->get('id'), 'AND:thread:=' => $thread->get('id')));
             $c->sortby('createdon', 'DESC');
             $c->limit(1);
             /** @var disPost $priorPost */
             $priorPost = $this->xpdo->getObject('disPost', $c);
             if ($priorPost) {
                 /* set last post anew */
                 $thread->set('post_last', $priorPost->get('id'));
                 $thread->set('post_last_on', strtotime($priorPost->get('createdon')));
                 $thread->set('author_last', $priorPost->get('author'));
                 /* fix thread participants */
                 $thread->removeParticipant($this->get('author'), $this->get('id'));
                 $saved = $thread->save();
             } else {
                 /* if no more posts, remove thread */
                 $thread->remove();
             }
         }
         /* adjust forum activity */
         if (!defined('DISCUSS_IMPORT_MODE') && !$isPrivateMessage) {
             $now = date('Y-m-d');
             /** @var disForumActivity $activity */
             $activity = $this->xpdo->getObject('disForumActivity', array('day' => $now));
             if ($activity) {
                 if ($this->get('parent') != 0) {
                     $activity->set('replies', $activity->get('replies') - 1);
                 } else {
                     $activity->set('topics', $activity->get('topics') - 1);
                 }
                 $activity->save();
             }
         }
         $this->removeFromIndex();
         $this->xpdo->invokeEvent('OnDiscussPostRemove', array('post' => &$this, 'thread' => &$thread, 'doBoardMoveChecks' => $doBoardMoveChecks, 'moveToSpam' => $moveToSpam, 'moved' => $moved, 'isPrivateMessage' => $isPrivateMessage));
         $this->clearCache();
     }
     return $removed;
 }
 public function remove(array $ancestors = array())
 {
     $filename = $this->get('filename');
     if (!empty($filename)) {
         $filename = $this->xpdo->call('galAlbum', 'getFilesPath', array(&$this->xpdo)) . $filename;
         $filename = str_ireplace(MODX_BASE_PATH, '', $filename);
         $ms = $this->getMediaSource();
         if (!@$ms->removeObject($filename)) {
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, '[Gallery] An error occurred while trying to remove the attachment file at: ' . $filename);
         }
     }
     return parent::remove($ancestors);
 }
Beispiel #16
0
 /**
  * @param array $ancestors
  *
  * @return bool
  */
 public function remove(array $ancestors = array())
 {
     if ($this->prepareSource() === true) {
         if ($this->mediaSource->removeObject($this->get('path') . $this->get('file'))) {
             if (!($thumbs = $this->get('thumbs'))) {
                 $thumbs = array('thumb' => $this->get('thumb'));
             }
             foreach ($thumbs as $thumb) {
                 if (empty($thumb)) {
                     continue;
                 }
                 $tmp = explode('/', $thumb);
                 $filename = end($tmp);
                 $this->mediaSource->removeObject($this->get('path') . $filename);
             }
         }
         /*
         else {
         	$this->xpdo->log(xPDO::LOG_LEVEL_ERROR,
         		'[Tickets] Could not remove file at "' . $this->get('path') . $this->get('file') . '": ' . $this->mediaSource->errors['file']
         	);
         }
         */
     }
     return parent::remove($ancestors);
 }
 /**
  * @param array $ancestors
  *
  * @return bool
  */
 public function remove(array $ancestors = array())
 {
     $this->prepareSource();
     if (!$this->mediaSource->removeObject($this->get('path') . $this->get('file'))) {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Could not remove file at "' . $this->get('path') . $this->get('file') . '": ' . $this->mediaSource->errors['file']);
     }
     return parent::remove($ancestors);
 }
 /**
  * @param array $ancestors
  *
  * @return bool
  */
 public function remove(array $ancestors = array())
 {
     $collection = $this->xpdo->getIterator('TicketComment', array('parent' => $this->id));
     /** @var TicketComment $item */
     foreach ($collection as $item) {
         $item->remove();
     }
     /** @var TicketAuthor $profile */
     if ($profile = $this->xpdo->getObject('TicketAuthor', $this->get('createdby'))) {
         $profile->removeAction('comment', $this->id, $this->get('createdby'));
     }
     return parent::remove($ancestors);
 }
 /**
  * @param array $ancestors
  *
  * @return bool
  */
 public function remove(array $ancestors = array())
 {
     $this->xpdo->removeCollection('msdCoupon', array('group_id' => $this->get('id')));
     return parent::remove($ancestors);
 }
Beispiel #20
0
 /**
  * Override remove() to clear thread cache
  *
  * @param array $ancestors
  * @param boolean $doBoardMoveChecks
  * @param boolean $moveToSpam
  * @return boolean
  */
 public function remove(array $ancestors = array(), $doBoardMoveChecks = false, $moveToSpam = false)
 {
     $removed = false;
     if (!empty($doBoardMoveChecks)) {
         $board = $this->getOne('Board');
         if (!empty($board) && !$this->get('private')) {
             $isModerator = $board->isModerator($this->xpdo->discuss->user->get('id'));
             $isAdmin = $this->xpdo->discuss->user->isAdmin();
             if ($isModerator || $isAdmin) {
                 /* move to spambox/recyclebin */
                 $spamBoard = $this->xpdo->getOption('discuss.spam_bucket_board', null, false);
                 if ($moveToSpam && !empty($spamBoard) && $spamBoard != $this->get('board')) {
                     if ($this->move($spamBoard)) {
                         $removed = true;
                     }
                 } else {
                     $trashBoard = $this->xpdo->getOption('discuss.recycle_bin_board', null, false);
                     if (!empty($trashBoard) && $trashBoard != $this->get('board')) {
                         if ($this->move($trashBoard)) {
                             $removed = true;
                         }
                     }
                 }
             }
         }
     }
     if (!$removed) {
         $removed = parent::remove($ancestors);
     }
     if ($removed) {
         $this->clearCache();
         /* clear recent posts cache */
         $this->xpdo->cacheManager->delete('discuss/board/recent/');
         $this->xpdo->cacheManager->delete('discuss/recent/');
     }
     return $removed;
 }
 /**
  * @param array $ancestors
  *
  * @return bool
  */
 public function remove(array $ancestors = array())
 {
     $res = $this->prepareSource();
     if ($res !== true) {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Could not initialize media source:"' . $res . '"');
         return $res;
     }
     if (!$this->mediaSource->removeObject($this->get('path') . $this->get('file'))) {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Could not remove file at "' . $this->get('path') . $this->get('file') . '": ' . $this->mediaSource->errors['file']);
     }
     $children = $this->xpdo->getIterator('msResourceFile', array('parent' => $this->get('id')));
     /** @var msResourceFile $child */
     foreach ($children as $child) {
         $child->remove();
     }
     return parent::remove($ancestors);
 }
Beispiel #22
0
 /** {@inheritdoc} */
 public function remove(array $ancestors = array())
 {
     $eventName = $this->get('name');
     $this->xpdo->virtualpage->doEvent('remove', $eventName, 'vpEvent', 10);
     return parent::remove();
 }
Beispiel #23
0
 /**
  * Override xPDOObject::remove to clear cache on remove
  * @param array $ancestors
  * @return boolean
  */
 public function remove(array $ancestors = array())
 {
     $removed = parent::remove($ancestors);
     $this->clearCache();
     return $removed;
 }
 /**
  * @param array $ancestors
  *
  * @return bool
  */
 public function remove(array $ancestors = array())
 {
     $collection = $this->xpdo->getIterator('TicketComment', array('thread' => $this->id, 'parent' => 0));
     /** @var TicketComment $item */
     foreach ($collection as $item) {
         $item->remove();
     }
     return parent::remove($ancestors);
 }