/** * This function load's all user groups * **/ function init() { $sql = "SELECT * FROM #__byjg_groups WHERE ownerid=" . $this->_ownerID; $this->_db->setQuery($sql); if ($this->_db->query() === false) { ByJGError::Alert(JText::_('BYJG_SQLQUERY_ERROR')); exit; } $lst = $this->_db->loadObjectList(); foreach ($lst as $l) { $g = new ByJGGroup(); $g->init($l->name); $this->_groups[] = $g; } }
/** * This function returns the complete user sms archive * **/ function getArchiveTotalCount() { $sql = "SELECT COUNT(*) FROM #__byjg_sendsms WHERE userid=" . $this->_ownerID; $this->_db->setQuery($sql); if ($this->_db->query() === false) { ByJGError::Alert(JText::_('BYJG_SQLQUERY_ERROR')); die; } return $this->_db->loadRow(); }
/** * This function returns true if the new balance can be set otherwise false * **/ function setBalance($credits) { //check input if (!is_numeric($credits)) { return false; } //check if user is blocked if ($this->isBlocked() == true) { return false; } $sql = "UPDATE #__byjg_joomlauser SET credits=" . $credits . " WHERE id=" . $this->_byjgId . " AND userid=" . $this->_joomId; $this->_db->setQuery($sql); if ($this->_db->query() === false) { ByJGError::Alert(JText::_('BYJG_SQLQUERY_ERROR')); die; } $this->_credits = $credits; return true; }
function delete() { //first delete all entries from #__byjg_usergroups $sql = "DELETE FROM #__byjg_usergroups WHERE groupid={$this->_id}"; $this->_db->setQuery($sql); if ($this->_db->query() === false) { ByJGError::Alert(JText::_('BYJG_SQLQUERY_ERROR')); die; } //now delete group itself from #__byjg_groups $sql = "DELETE FROM #__byjg_groups WHERE id={$this->_id}"; $this->_db->setQuery($sql); if ($this->_db->query() === false) { ByJGError::Alert(JText::_('BYJG_SQLQUERY_ERROR')); die; } }