Ejemplo n.º 1
0
 /**
  * Delete an object from the database
  * @see XoopsPersistableObjectHandler
  *
  * @param XoopsObject|ProfileRegstep $obj
  * @param bool $force
  *
  * @return bool
  */
 public function deleteRegstep(XoopsObject $obj, $force = false)
 {
     if (parent::delete($obj, $force)) {
         $field_handler = \Xoops::getModuleHelper('profile')->getHandler('field');
         return $field_handler->updateAll('step_id', 0, new Criteria('step_id', $obj->getVar('step_id')));
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Delete an object from the database
  * @see XoopsPersistableObjectHandler
  *
  * @param XoopsObject|ProfileRegstep $obj
  * @param bool $force
  *
  * @return bool
  */
 public function deleteRegstep(XoopsObject $obj, $force = false)
 {
     if (parent::delete($obj, $force)) {
         $xoops = Xoops::getInstance();
         $field_handler = $xoops->getModuleHandler('field');
         return $field_handler->updateAll('step_id', 0, new Criteria('step_id', $obj->getVar('step_id')));
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * Delete a ID from the database
  *
  * @param XoopsBlock $obj object to delete
  *
  * @return bool
  */
 public function deleteBlock(XoopsBlock $obj)
 {
     if (!parent::delete($obj)) {
         return false;
     }
     $qb = $this->db2->createXoopsQueryBuilder();
     $eb = $qb->expr();
     $qb->deletePrefix('system_permission', null)->where($eb->eq('gperm_name', $eb->literal('block_read')))->andWhere($eb->eq('gperm_itemid', $qb->createNamedParameter($obj->getVar('bid'), \PDO::PARAM_INT)))->andWhere($eb->eq('gperm_modid', $qb->createNamedParameter(1, \PDO::PARAM_INT)))->execute();
     $qb->deletePrefix('system_blockmodule', null)->where($eb->eq('block_id', $qb->createNamedParameter($obj->getVar('bid'), \PDO::PARAM_INT)))->execute();
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Mark a message as to_delete = 1 or removes it if the sender has also deleted it or sent by anonymous
  *
  * @param XoopsObject|PmMessage $pm
  * @param int $val
  * @return bool
  */
 public function setTodelete(PmMessage $pm, $val = 1)
 {
     if ($pm->getVar('from_delete') == 0 && $pm->getVar('from_userid') == 0) {
         return $this->updateAll('to_delete', (int) $val, new Criteria('msg_id', $pm->getVar('msg_id')));
     } else {
         return parent::delete($pm);
     }
 }
Ejemplo n.º 5
0
 /**
  * delete a file from the database
  *
  * @param XoopsObject|PublisherFile $file reference to the file to delete
  * @param bool   $force
  *
  * @return bool FALSE if failed.
  */
 public function delete(XoopsObject $file, $force = false)
 {
     $ret = false;
     // Delete the actual file
     if (is_file($file->getFilePath()) && unlink($file->getFilePath())) {
         $ret = parent::delete($file, $force);
     }
     return $ret;
 }
Ejemplo n.º 6
0
 /**
  * Delete a module from the database
  *
  * @param XoopsModule $module module to delete
  *
  * @return bool
  */
 public function deleteModule(XoopsModule $module)
 {
     if (!parent::delete($module)) {
         return false;
     }
     $mid = $module->getVar('mid');
     $dirname = $module->getVar('dirname');
     // delete admin and read permissions assigned for this module
     $qb = $this->db2->createXoopsQueryBuilder();
     $eb = $qb->expr();
     $qb->deletePrefix('system_permission')->where($eb->orX($eb->eq('gperm_name', $eb->literal('module_admin')), $eb->eq('gperm_name', $eb->literal('module_read'))))->andWhere($eb->eq('gperm_itemid', ':itemid'))->setParameter(':itemid', $mid, \PDO::PARAM_INT)->execute();
     $qb->resetQueryParts();
     // reset
     $qb->select('block_id')->fromPrefix('system_blockmodule', null)->where($eb->eq('module_id', ':mid'))->setParameter(':mid', $mid, \PDO::PARAM_INT);
     $result = $qb->execute();
     $block_id_arr = array();
     while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
         array_push($block_id_arr, $myrow['block_id']);
     }
     foreach ($block_id_arr as $i) {
         $qb->resetQueryParts();
         // reset
         $qb->select('COUNT(*)')->fromPrefix('system_blockmodule', null)->where($eb->ne('module_id', ':mid'))->setParameter(':mid', $mid, \PDO::PARAM_INT)->andWhere($eb->eq('block_id', ':bid'))->setParameter(':bid', $i, \PDO::PARAM_INT);
         $result = $qb->execute();
         $count = $result->fetchColumn(0);
         if ($count > 0) {
             // this block has other entries, so delete the entry for this module
             $qb->resetQueryParts();
             // reset
             $qb->deletePrefix('system_blockmodule')->where($eb->eq('module_id', ':mid'))->setParameter(':mid', $mid, \PDO::PARAM_INT)->andWhere($eb->eq('block_id', ':bid'))->setParameter(':bid', $i, \PDO::PARAM_INT)->execute();
         } else {
             // this block does not have other entries, so disable the block and let it show
             // on top page only. otherwise, this block will not display anymore on block admin page!
             $qb->resetQueryParts();
             // reset
             $qb->updatePrefix('system_block')->set('visible', ':notvisible')->where($eb->eq('bid', ':bid'))->setParameter(':bid', $i, \PDO::PARAM_INT)->setParameter(':notvisible', 0, \PDO::PARAM_INT)->execute();
             $qb->resetQueryParts();
             // reset
             $qb->updatePrefix('system_blockmodule')->set('module_id', ':nomid')->where($eb->eq('module_id', ':mid'))->setParameter(':mid', $mid, \PDO::PARAM_INT)->setParameter(':nomid', -1, \PDO::PARAM_INT)->execute();
         }
     }
     if (!empty($this->cachedModulesByDirname[$dirname])) {
         unset($this->cachedModulesByDirname[$dirname]);
     }
     if (!empty($this->cachedModulesByMid[$mid])) {
         unset($this->cachedModulesByMid[$mid]);
     }
     $cache = \Xoops::getInstance()->cache();
     $cache->delete("system/module/id/{$mid}");
     $cache->delete("system/module/dirname/{$dirname}");
     $cache->delete("module/{$dirname}");
     return true;
 }
Ejemplo n.º 7
0
 /**
  * delete a category from the database
  *
  * @param XoopsObject $category reference to the category to delete
  * @param bool        $force
  *
  * @return bool FALSE if failed.
  */
 public function delete(XoopsObject $category, $force = false)
 {
     $xoops = Xoops::getInstance();
     // Deleting this category ITEMs
     $criteria = new Criteria('categoryid', $category->getVar('categoryid'));
     $this->publisher->getItemHandler()->deleteAll($criteria, true, true);
     unset($criteria);
     // Deleting the sub categories
     $subcats = $this->getCategories(0, 0, $category->getVar('categoryid'));
     foreach ($subcats as $subcat) {
         $this->delete($subcat);
     }
     if (!parent::delete($category, $force)) {
         $category->setErrors('An error while deleting.');
         return false;
     }
     $module_id = $this->publisher->getModule()->getVar('mid');
     $xoops->getHandlerGroupPermission()->deleteByModule($module_id, "category_read", $category->getVar('categoryid'));
     $xoops->getHandlerGroupPermission()->deleteByModule($module_id, "item_submit", $category->getVar('categoryid'));
     $xoops->getHandlerGroupPermission()->deleteByModule($module_id, "category_moderation", $category->getVar('categoryid'));
     return true;
 }
Ejemplo n.º 8
0
 /**
  * delete an item from the database
  *
  * @param XoopsObject $item reference to the ITEM to delete
  * @param bool        $force
  *
  * @return bool FALSE if failed.
  */
 public function delete(XoopsObject $item, $force = false)
 {
     $xoops = Xoops::getInstance();
     // Deleting the files
     if (!$this->publisher->getFileHandler()->deleteItemFiles($item)) {
         $item->setErrors('An error while deleting a file.');
     }
     if (!parent::delete($item, $force)) {
         $item->setErrors('An error while deleting.');
         return false;
     }
     // Removing tags information
     if ($xoops->isActiveModule('tag')) {
         $tag_handler = $xoops->getModuleHandler('tag', 'tag');
         $tag_handler->updateByItem('', $item->getVar('itemid'), PUBLISHER_DIRNAME, 0);
     }
     return true;
 }
Ejemplo n.º 9
0
 /**
  * delete a profile field from the database
  *
  * @param XoopsObject|ProfileField $obj reference to the object to delete
  * @param bool $force
  * @return bool FALSE if failed.
  **/
 public function deleteFields(XoopsObject $obj, $force = false)
 {
     $xoops = Xoops::getInstance();
     $profile_handler = \Xoops::getModuleHelper('profile')->getHandler('profile');
     // remove column from table
     $sql = "ALTER TABLE " . $profile_handler->table . " DROP `" . $obj->getVar('field_name', 'n') . "`";
     if ($this->db2->query($sql)) {
         //change this to update the cached field information storage
         if (!parent::delete($obj, $force)) {
             return false;
         }
         if ($obj->getVar('field_show') || $obj->getVar('field_edit')) {
             $profile_module = $xoops->getModuleByDirname('profile');
             if (is_object($profile_module)) {
                 // Remove group permissions
                 $groupperm_handler = $xoops->getHandlerGroupPermission();
                 $criteria = new CriteriaCompo(new Criteria('gperm_modid', $profile_module->getVar('mid')));
                 $criteria->add(new Criteria('gperm_itemid', $obj->getVar('field_id')));
                 return $groupperm_handler->deleteAll($criteria);
             }
         }
     }
     return false;
 }