Exemple #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;
 }
Exemple #2
0
 public function countRelated($start = 0, $limit = 0, $sort = 'related_name', $order = 'ASC')
 {
     $criteria = new CriteriaCompo();
     $criteria->setSort($sort);
     $criteria->setOrder($order);
     $criteria->setStart($start);
     $criteria->setLimit($limit);
     return parent::getCount();
 }
Exemple #3
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;
 }
 /**
  * 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;
 }
Exemple #5
0
 public function getStats($content_id)
 {
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('rating_content_id', $content_id));
     $i = 0;
     $total = 0;
     $obj = parent::getAll($criteria);
     foreach ($obj as $k => $v) {
         ++$i;
         $total += $v->getVar('rating_rating');
     }
     return array('voters' => $i, 'average' => $total / $i);
 }
Exemple #6
0
 /**
  * @param CriteriaElement|null $criteria
  * @param bool $id_as_key
  *
  * @return array
  */
 public function getPermittedObjects($criteria = null, $start = 0, $limit = 0, $id_as_key = false, $asobject = true)
 {
     $this->table_link = $this->db2->prefix('system_permission');
     if (isset($criteria)) {
         $criteria = new CriteriaCompo($criteria);
     } else {
         $criteria = new CriteriaCompo();
     }
     $criteria->setSort('o.imgcat_weight, o.imgcat_id');
     $criteria->setOrder('ASC');
     $criteria->setStart($start);
     $criteria->setLimit($limit);
     return parent::getByLink($criteria, null, $asobject, 'gperm_itemid', 'imgcat_id');
 }
Exemple #7
0
 /**
  * Constructor
  *
  * @param Connection|null $db {@link Connection}
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'groups', 'XoopsGroup', 'groupid', 'name');
 }
 /**
  * Constructor
  *
  * @param Connection|null $db database
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'system_privatemessage', '\\Xoops\\Core\\Kernel\\Handlers\\XoopsPrivateMessage', 'msg_id', 'subject');
 }
Exemple #9
0
 /**
  * Constructor
  *
  * @param Connection|null $db {@link Connection}
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'userconfigs_option', 'UserconfigsOption', 'confop_id', 'confop_name');
 }
Exemple #10
0
 /**
  * Constructor
  *
  * @param Connection|null $db {@link Connection}
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'config', 'XoopsConfigItem', 'conf_id', 'conf_name');
 }
Exemple #11
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;
 }
Exemple #12
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;
 }
Exemple #13
0
 /**
  * Constructor
  *
  * @param Connection|null $db {@link Connection}
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'comments', 'CommentsComment', 'id', 'title');
 }
 /**
  * __construct
  *
  * @param null|Connection $db database
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'system_blockmodule', '\\Xoops\\Core\\Kernel\\Handlers\\XoopsBlockModuleLink', 'block_id', 'module_id');
 }
Exemple #15
0
 /**
  * @param null|Connection $db database
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'profile_visibility', 'profilevisibility', 'field_id');
 }
 /**
  * Constructor
  *
  * @param Connection|null $db database
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'system_configoption', '\\Xoops\\Core\\Kernel\\Handlers\\XoopsConfigOption', 'confop_id', 'confop_name');
 }
Exemple #17
0
 /**
  * @param Connection $db
  */
 public function __construct(Connection $db)
 {
     parent::__construct($db, 'userrank_rank', 'UserrankRank', 'rank_id', 'rank_title');
 }
Exemple #18
0
 /**
  * @param null|Connection $db database
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'profile_category', 'profilecategory', 'cat_id', 'cat_title');
 }
Exemple #19
0
 /**
  * @param null|Xoops\Core\Database\Connection $db
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'publisher_rating', 'PublisherRating', 'ratingid', 'itemid');
 }
Exemple #20
0
 public function getActiveSmilies($asobject = true)
 {
     $criteria = new CriteriaCompo(new Criteria('smiley_display', 1));
     return parent::getAll($criteria, false, $asobject);
 }
Exemple #21
0
 /**
  * @param null|Connection $db database
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'banners_banner', 'BannersBanner', 'banner_bid', 'banner_imageurl');
 }
Exemple #22
0
 /**
  * Constructor
  *
  * @param Connection|null $db {@link Connection}
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'userconfigs_item', 'UserconfigsItem', 'conf_id', 'conf_name');
 }
 /**
  * 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;
 }
Exemple #24
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;
 }
Exemple #25
0
 /**
  * @param bool $asobject
  *
  * @return array
  */
 public function getAllLanguage($asobject = true)
 {
     $criteria = new CriteriaCompo();
     $criteria->setSort('xlanguage_weight');
     $criteria->setOrder('asc');
     return parent::getAll($criteria, null, $asobject, true);
 }
 /**
  * Constructor
  *
  * @param Connection|null $db database
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'system_permission', '\\Xoops\\Core\\Kernel\\Handlers\\XoopsGroupPerm', 'gperm_id', 'gperm_name');
 }
Exemple #27
0
 /**
  * Constructor
  *
  * @param Connection|null $db {@link Connection}
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'online', 'XoopsOnline', 'online_uid', 'online_uname');
 }
Exemple #28
0
 /**
  * Constructor
  *
  * @param Connection|null $db {@link Connection}
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'notifications', 'NotificationsNotification', 'id', 'itemid');
 }
Exemple #29
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);
     }
 }
 /**
  * Constructor
  *
  * @param Connection|null $db database
  */
 public function __construct(Connection $db = null)
 {
     parent::__construct($db, 'system_user', '\\Xoops\\Core\\Kernel\\Handlers\\XoopsUser', 'uid', 'uname');
 }