? Failure

User tests: Successful: Unsuccessful:

avatar jackkum
jackkum
25 Dec 2014

On my project users sync with accounting software, creating user and contact from cli script.

// We are a valid entry point.
const _JEXEC = 1;

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);

// Load system defines
if (file_exists(dirname(DIR) . '/defines.php'))
{
require_once dirname(DIR) . '/defines.php';
}

if (!defined('JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR_
));
require_once JPATH_BASE . '/includes/defines.php';
}

require_once JPATH_CONFIGURATION . '/configuration.php';

require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';

$config = new JConfig;

error_reporting(E_ALL);
ini_set('display_errors', 1);

// im doing something wrong, without this have warnings
$_SERVER['HTTP_HOST'] = 'example.com';
$_SERVER['REQUEST_URI'] = NULL;

// init session
JFactory::getSession();
// admin app
JFactory::getApplication('administrator');

class JContactAddCli extends JApplicationCli
{
public function doExecute()
{
jimport('joomla.user.helper');
$user_id = $this->input->getInt('user');
$catid = $this->input->getInt('catid', 0);

       if( ! $user_id){
           $this->out("Input user", TRUE);
           return FALSE;
       }
       // ...
       $contactsModel = FOFModel::getAnInstance('Contacts', 'ContactModel');
       $contactsModel->setState('filter.user_id', $user_id);
       $contactsModel->getItems();
       // ...
    }

}

add to method ContactModelContacts::getListQuery() filter:
if (($user_id = $this->getState('filter.user_id')))
{
$query->where('a.user_id = ' . (int) $user_id);
}

avatar jackkum jackkum - open - 25 Dec 2014
avatar jissues-bot jissues-bot - change - 25 Dec 2014
Labels Added: ?
avatar jackkum jackkum - close - 25 Dec 2014
avatar jackkum jackkum - change - 25 Dec 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-12-25 05:06:26

Add a Comment

Login with GitHub to post a comment