Ejemplo n.º 1
0
 /**
  * Generic save function
  *
  * @access	public
  * @param	array	Source array for binding to class vars
  * @param	string	Filter for the order updating
  * @param	mixed	An array or space separated list of fields not to bind
  * @returns TRUE if completely successful, FALSE if partially or not succesful.
  */
 function save($source, $order_filter = '', $ignore = '')
 {
     if (!$this->bind($source, $ignore)) {
         return false;
     }
     if (!$this->check()) {
         return false;
     }
     if (!$this->store()) {
         return false;
     }
     if (!$this->checkin()) {
         return false;
     }
     if ($order_filter) {
         $filter_value = $this->{$order_filter};
         $this->reorder($order_filter ? $this->_db->nameQuote($order_filter) . ' = ' . $this->_db->Quote($filter_value) : '');
     }
     $this->setError('');
     return true;
 }
Ejemplo n.º 2
0
 protected function _getAutoComplete($do, $data)
 {
     $result = array();
     // only registered users when the board is online will endup here
     // Verify permissions
     if ($this->_session->allowed && $this->_session->allowed != 'na') {
         $allowed = "c.id IN ({$this->_session->allowed})";
     } else {
         $allowed = "c.published='1' AND c.pub_access='0'";
     }
     // When we query for topics or categories we have to check against permissions
     switch ($do) {
         case 'getcat':
             $query = "SELECT c.name, c.id\n\t\t\t\t\t\t\tFROM #__kunena_categories AS c\n\t\t\t\t\t\t\tWHERE {$allowed} AND name LIKE '" . $data . "%'\n\t\t\t\t\t\t\tORDER BY 1 LIMIT 0, 10;";
             $this->_db->setQuery($query);
             $result = $this->_db->loadResultArray();
             break;
         case 'gettopic':
             $query = "SELECT m.subject\n\t\t\t\t\t\t\tFROM #__kunena_messages AS m\n\t\t\t\t\t\t\tJOIN #__kunena_categories AS c ON m.catid = c.id\n\t\t\t\t\t\t\tWHERE m.hold=0 AND m.parent=0 AND {$allowed}\n\t\t\t\t\t\t\t\tAND m.subject LIKE '" . $data . "%'\n\t\t\t\t\t\t\tORDER BY 1 LIMIT 0, 10;";
             $this->_db->setQuery($query);
             $result = $this->_db->loadResultArray();
             break;
         case 'getuser':
             $kunena_config = KunenaFactory::getConfig();
             // User the configured display name
             $queryname = $kunena_config->username ? 'username' : 'name';
             // Exclude the main superadmin from the search for security purposes
             $query = "SELECT {$this->_db->nameQuote($queryname)} FROM #__users WHERE block=0 AND `id` != 62 AND {$this->_db->nameQuote($queryname)}\n\t\t\t\t\t\t\tLIKE {$this->_db->Quote("{$data}%")} ORDER BY 1 LIMIT 0, 10;";
             $this->_db->setQuery($query);
             $result = $this->_db->loadResultArray();
             break;
         default:
             // Operation not supported
             $result = array('status' => '-1', 'error' => JText::_('COM_KUNENA_AJAX_INVALID_OPERATION'));
     }
     if ($this->_db->getErrorNum()) {
         $result = array('status' => '-1', 'error' => KunenaError::getDatabaseError());
     }
     return $result;
 }