/**
  * Returns an array of lists received from the previous page; otherwise, fetches lists from the set screen name.
  * 
  */
 protected function getLists($strScreenName = '')
 {
     // If the cache is set from the previous page, use that.
     $strListTransient = isset($_GET['list_cache']) ? $_GET['list_cache'] : '';
     if (!empty($strListTransient)) {
         $arrLists = (array) get_transient($strListTransient);
         delete_transient($strListTransient);
         return $arrLists;
     }
     if (empty($strScreenName)) {
         return array();
     }
     // Fetch lists from the given screen name.
     $oFetch = new FetchTweets_Fetch();
     $arrLists = $oFetch->getListNamesFromScreenName($strScreenName);
     return $arrLists;
 }
 /**
  * Returns an array of lists received from the previous page; otherwise, fetches lists from the set screen name.
  * 
  */
 protected function _getLists($sScreenName = '', $iAccountID = 0)
 {
     // If the cache is set from the previous page, use that.
     $sListTransient = isset($_GET['list_cache']) ? $_GET['list_cache'] : '';
     if (!empty($sListTransient)) {
         $aLists = FetchTweets_WPUtilities::getTransient($sListTransient, array());
         FetchTweets_WPUtilities::deleteTransient($sListTransient);
         return $aLists;
     }
     if (empty($sScreenName)) {
         return array();
     }
     // Fetch lists from the given screen name.
     $_oOption =& $GLOBALS['oFetchTweets_Option'];
     $_aCredentials = $_oOption->getCredentialsByID($iAccountID);
     $oFetch = new FetchTweets_Fetch($_aCredentials['consumer_key'], $_aCredentials['consumer_secret'], $_aCredentials['access_token'], $_aCredentials['access_secret']);
     $aLists = $oFetch->getListNamesFromScreenName($sScreenName, $iAccountID);
     return $aLists;
 }
 /**
  * Validates submitted form data of the page. 
  * @remark validation_{page slug}
  * 
  * @since       unknown
  * @since       2.4.5       Changed the name from 'validation_fetch_tweets_add_rule_by_list'.
  */
 public function validatePageFormData($aInput, $aOldInput, $oFactory, $aSubmitInformation)
 {
     // Check if the input has been properly sent.
     if (!isset($aInput['add_rule_by_list']['list_owner_screen_name'], $aInput['add_rule_by_list']['list_owner_accounts'])) {
         $oFactory->setSettingNotice(__('Something went wrong. Your input could not be received. Try again and if this happens again, contact the developer.', 'fetch-tweets'));
         return $aOldInput;
     }
     $_aCredentials = $this->_getCredentiaslByAccountID($aInput['add_rule_by_list']['list_owner_accounts']);
     // Variables
     $_aErrors = array();
     // error array
     $_iAccountID = $aInput['add_rule_by_list']['list_owner_accounts'] == -1 ? 0 : $aInput['add_rule_by_list']['list_owner_accounts'];
     $_sOwnerScreenName = $aInput['add_rule_by_list']['list_owner_accounts'] == '-1' ? $aInput['add_rule_by_list']['list_owner_screen_name'] : $_aCredentials['screen_name'];
     // The list owner screen name must be provided.
     if (empty($_sOwnerScreenName)) {
         $_aErrors['add_rule_by_list']['list_owner_screen_name'] = __('The screen name of the list owner must be specified: ') . $_sOwnerScreenName;
         $oFactory->setFieldErrors($_aErrors);
         $oFactory->setSettingNotice(__('There was an error in your input.', 'fetch-tweets'));
         return $aOldInput;
     }
     // Fetch the lists by the screen name.
     $_oFetch = new FetchTweets_Fetch($_aCredentials['consumer_key'], $_aCredentials['consumer_secret'], $_aCredentials['access_token'], $_aCredentials['access_secret']);
     $_aLists = $_oFetch->getListNamesFromScreenName($_sOwnerScreenName, $_iAccountID);
     if (empty($_aLists)) {
         $oFactory->setSettingNotice(__('No list found.', 'fetch-tweets'));
         return $aOldInput;
     }
     // Set the transient of the fetched IDs. This will be used right next page load.
     $_sListCacheID = uniqid();
     FetchTweets_WPUtilities::setTransient($_sListCacheID, $_aLists, 60);
     exit(wp_redirect(add_query_arg(array('post_type' => FetchTweets_Commons::PostTypeSlug, 'tweet_type' => 'list', 'list_cache' => $_sListCacheID, 'screen_name' => $_sOwnerScreenName, 'account_id' => $_iAccountID), admin_url('post-new.php'))));
 }
 public function validation_fetch_tweets_add_rule_by_list($arrInput, $arrOriginal)
 {
     // Check if the input has been properly sent.
     if (!isset($arrInput['fetch_tweets_add_rule_by_list']['add_rule_by_list']['list_owner_screen_name'])) {
         $this->setSettingNotice(__('Something went wrong. Your input could not be received. Try again and if this happens again, contact the developer.', 'fetch-tweets'));
         return $arrOriginal;
     }
     // Variables
     $fVerified = true;
     // flag
     $arrErrors = array();
     // error array
     $strOwnerScreenName = $arrInput['fetch_tweets_add_rule_by_list']['add_rule_by_list']['list_owner_screen_name'];
     // The list owner screen name must be provided.
     if (empty($strOwnerScreenName)) {
         $arrErrors['add_rule_by_list']['list_owner_screen_name'] = __('The screen name of the list owner must be specified: ') . $strOwnerScreenName;
         $this->setFieldErrors($arrErrors);
         $this->setSettingNotice(__('There was an error in your input.', 'fetch-tweets'));
         return $arrOriginal;
     }
     // Fetch the lists by the screen name.
     $oFetch = new FetchTweets_Fetch();
     $arrLists = $oFetch->getListNamesFromScreenName($strOwnerScreenName);
     if (empty($arrLists)) {
         $this->setSettingNotice(__('No list found.', 'fetch-tweets'));
         return $arrOriginal;
     }
     // Set the transient of the fetched IDs. This will be used right next page load.
     $strListCacheID = uniqid();
     set_transient($strListCacheID, $arrLists, 60);
     $this->oUtil->goRedirect(admin_url("post-new.php?post_type=fetch_tweets&tweet_type=list&list_cache={$strListCacheID}&screen_name={$strOwnerScreenName}"));
 }