本文整理汇总了PHP中xPDOSimpleObject::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDOSimpleObject::remove方法的具体用法?PHP xPDOSimpleObject::remove怎么用?PHP xPDOSimpleObject::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDOSimpleObject
的用法示例。
在下文中一共展示了xPDOSimpleObject::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
/**
* 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;
}
示例2: remove
/** {@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();
}
示例3: 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;
}
示例4: remove
/**
* {@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();
}
示例5: remove
public function remove(array $ancestors = array())
{
$remove = parent::remove($ancestors);
/** @var msdCouponGroup $group */
if ($group = $this->getOne('Group')) {
$group->updateCounters();
}
return $remove;
}
示例6: 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);
}
示例7: remove
/**
* @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;
}
示例8: remove
/**
* 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;
}
示例9: remove
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;
}
示例10: remove
/**
* 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;
}
示例11: remove
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;
}
示例12: remove
/**
* 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;
}
示例13: remove
/**
* @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);
}
示例14: remove
/**
* 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) {
//.........这里部分代码省略.........
示例15: remove
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);
}