Example #1
0
 /**
  * Retrieves User Data.
  *
  * Thie method first checks the local cache database and if needed calls
  * twitter for more information
  *
  * @param string $username
  * @return stdClass
  */
 private function getUserData($username)
 {
     $reCacheCutoff = new DateTime();
     $reCacheCutoff->modify("-15 days");
     //Check cache
     $data = $this->dbManager->get_row("SELECT *, DATE_FORMAT(cached_on, '%Y%m%d%h%i%s') AS cacheint FROM " . $this->dbManager->getTableNameFor('user_data_cache') . " WHERE twitter = '" . $username . "'");
     if ($data === null || $data->cacheint < $reCacheCutoff->format('YmdHis')) {
         //Get From Twitter
         $twData = Tweester_Twitter::getUserData($username);
         //Clear previous cache
         $this->dbManager->query("DELETE FROM " . $this->coreManager->getDbManager()->getTableNameFor('user_data_cache') . " WHERE twitter = '" . $username . "'");
         //Cache
         $this->dbManager->insert($this->dbManager->getTableNameFor('user_data_cache'), array('twitter' => $username, 'data' => json_encode($twData), 'cached_on' => date('Y-m-d H:i:s')), array('%s', '%s', '%s'));
         $userData = $twData;
     } else {
         $userData = json_decode($data->data);
     }
     return $userData;
 }
Example #2
0
 /**
  * Detects actions that need to be executed by the Settings page
  *
  * @todo find better way of accessing $_GET properties
  * @return string Message to be displayed
  */
 private function executeTasks()
 {
     //Read from $_GET
     if (isset($_GET['exec_action'])) {
         $action = $_GET['exec_action'];
     } else {
         $action = null;
     }
     switch ($action) {
         case 'run_update':
             $this->coreManager->getTaskManager()->updateAuthors();
             $msg = "Authors Updated";
             break;
         case 'clear_authors':
             $this->coreManager->getTaskManager()->clearAuthors();
             $msg = "Current Authors removed.";
             break;
         default:
             $msg = null;
     }
     return $msg;
 }
Example #3
0
 /**
  * Removes all authors currently in database
  */
 public function clearAuthors()
 {
     $query = "DELETE FROM " . $this->coreManager->getDbManager()->getTableNameFor('authors');
     $this->coreManager->getDbManager()->query($query);
 }