Example #1
0
 protected function getOptions()
 {
     $options = array();
     $this->value = array();
     // The selected values
     // Deduce table name from conventional names
     $input = new F0FInput();
     $component_prefix = ucfirst(str_replace('com_', '', $input->getString('option')));
     $view_prefix = ucfirst($input->getString('view'));
     // Deduce name of the relation
     $relation_name = @F0FInflector::pluralize($this->element['name']);
     // todo remove silence operator
     // Create a relation's model instance
     $relation_model = F0FModel::getTmpInstance(ucfirst($relation_name), $component_prefix . 'Model');
     // Get the name of key and title field
     $table = $relation_model->getTable();
     $key_field = $table->getKeyName();
     $value_field = $table->getColumnAlias('title');
     // List all items from the referred table
     foreach ($relation_model->getItemList(true) as $value) {
         $options[] = JHtmlSelect::option($value->{$key_field}, $value->{$value_field});
     }
     // Don't load selected values if item is new
     if ($id = $input->getInt('id')) {
         // Create an instance of the correct table and load this item
         $table = F0FTable::getInstance($view_prefix, $component_prefix . 'Table');
         // Load the instance of this item, based on ID query parameter
         $table->load($id);
         // Get the relation
         $relation = $table->getRelations()->getMultiple($relation_name);
         // Add existent relation as default selected values on list
         foreach ($relation as $item) {
             $this->value[] = $item->getId();
         }
     }
     return $options;
 }
Example #2
0
if (!version_compare($version, '5.3.0', '>=')) {
    return JError::raise(E_ERROR, 500, 'PHP versions 4.x, 5.0, 5.1 and 5.2 are no longer supported by AutoTweetNG.', 'The version of PHP used on your site is obsolete and contains known security vulenrabilities.
			Moreover, it is missing features required by AutoTweetNG to work properly or at all.
			Please ask your host to upgrade your server to the latest PHP 5.3/5.4 stable release. Thank you!');
}
if (!defined('AUTOTWEET_API')) {
    include_once JPATH_ADMINISTRATOR . '/components/com_autotweet/api/autotweetapi.php';
}
$config = array();
$view = null;
// If we are processing Gplus, redirect to controller
$session = JFactory::getSession();
$channelId = $session->get('channelId');
if (!empty($channelId)) {
    $input = new F0FInput();
    $code = $input->getString('code');
    if (!empty($code)) {
        $view = 'gpluschannels';
        $config['input'] = array('task' => 'callback');
    }
}
// If we are processing Frontend Twitter Channel Auth, redirect to controller
$authstate = $session->get('twitter-authstate');
if ($authstate) {
    $session->set('twitter-authstate', 0);
    $view = 'userchannels';
    $config['input'] = array('task' => 'twCallback');
}
// If we are processing Frontend LinkedIn Channel Auth, redirect to controller
$authstate = $session->get('linkedin-authstate');
if ($authstate) {
Example #3
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     $options = array();
     $this->value = array();
     $value_field = $this->element['value_field'] ? (string) $this->element['value_field'] : 'title';
     $input = new F0FInput();
     $component = ucfirst(str_replace('com_', '', $input->getString('option')));
     $view = ucfirst($input->getString('view'));
     $relation = F0FInflector::pluralize((string) $this->element['name']);
     $model = F0FModel::getTmpInstance(ucfirst($relation), $component . 'Model');
     $table = $model->getTable();
     $key = $table->getKeyName();
     $value = $table->getColumnAlias($value_field);
     foreach ($model->getItemList(true) as $option) {
         $options[] = JHtml::_('select.option', $option->{$key}, $option->{$value});
     }
     if ($id = F0FModel::getAnInstance($view)->getId()) {
         $table = F0FTable::getInstance($view, $component . 'Table');
         $table->load($id);
         $relations = $table->getRelations()->getMultiple($relation);
         foreach ($relations as $item) {
             $this->value[] = $item->getId();
         }
     }
     return $options;
 }
Example #4
0
if (!defined('AUTOTWEET_API')) {
    include_once JPATH_ADMINISTRATOR . '/components/com_autotweet/api/autotweetapi.php';
}
$base_url = EParameter::getComponentParam(CAUTOTWEETNG, 'base_url');
if (defined('AUTOTWEET_CRONJOB_RUNNING') && AUTOTWEET_CRONJOB_RUNNING && !filter_var($base_url, FILTER_VALIDATE_URL)) {
    throw new Exception('AUTOTWEET_CRONJOB: Url base not set.');
}
$config = array();
$controller = null;
// If we are processing Gplus, redirect to controller
$session = JFactory::getSession();
$channelId = $session->get('channelId');
if (!empty($channelId)) {
    $input = new F0FInput();
    // Google+ and Blogger
    $code = $input->getString('code');
    // ScoopIt
    $oauth_token = $input->getString('oauth_token');
    $oauth_verifier = $input->getString('oauth_verifier');
    // LinkedIn
    // $code = $input->getString('code');
    $state = $input->getString('state');
    if (!empty($oauth_token) && !empty($oauth_verifier) || !empty($code) && !empty($state) || !empty($code)) {
        $controller = F0FModel::getTmpInstance('Channeltypes', 'AutoTweetModel')->getAuthCallback($channelId);
        $config['input'] = array('task' => 'callback');
    } else {
        $session->set('channelId', false);
    }
}
// F0F app
F0FDispatcher::getTmpInstance('com_autotweet', $controller, $config)->dispatch();