/**
  * Scrape our albums
  * @since Version 3.10.0
  * @return \Railpage\Images\AlbumScraper
  */
 public function scrape()
 {
     $albums = $this->getMonitoredAlbums();
     foreach ($albums as $album) {
         Updater::ScrapeAlbum($album);
     }
     return $this;
 }
Exemple #2
0
 /**
  * Review an image
  * @since Version 3.10.0
  * @param \Railpage\Images\Image $imageObject
  * @param \Railpage\Users\User $userObject
  * @param boolean $publish
  * @param boolean $pick Does the screener think this is an exceptional photograph?
  * @return \Railpage\Images\Screener
  */
 public function reviewImage(Image $imageObject, User $userObject, $publish = 0, $pick = 0)
 {
     $publish = (bool) intval($publish);
     $pick = (bool) intval($pick);
     // If the screener hinks this is a worthy photo, why shouldn't we publish it?
     if ($pick == true) {
         $publish = true;
     }
     $query = sprintf("INSERT INTO image_flags (\r\n                image_id, published, screened, screened_by, screened_on, screened_pick, rejected\r\n            ) VALUES (\r\n                %d, %d, %d, %d, NOW(), %d, %d\r\n            ) ON DUPLICATE KEY UPDATE \r\n                published = VALUES(published), screened_by = VALUES(screened_by), \r\n                screened_on = NOW(), screened_pick = VALUES(screened_pick), rejected = VALUES(rejected)", $this->db->quote(intval($imageObject->id)), $publish, 1, $this->db->quote(intval($userObject->id)), $pick, !$publish);
     $this->db->query($query);
     /**
      * Delete it from the review skip table
      */
     $where = ["image_id = ?" => $imageObject->id];
     $this->db->delete("image_flags_skip", $where);
     if ($publish) {
         $imageObject = Utility\Updater::updateAuthor($imageObject);
     }
     return $this;
 }
Exemple #3
0
 /**
  * Favourite a photo
  * @since Version 3.10.0
  * @return void
  */
 public function setUserFavourite()
 {
     /**
      * Because I'll no doubt get confused - frequently - at the order of parameters, 
      * let's just be a sneaky bastard and check each parameter
      */
     $User = false;
     $Image = false;
     foreach (func_get_args() as $arg) {
         if ($arg instanceof User) {
             $User = $arg;
             continue;
         }
         if ($arg instanceof Image) {
             $Image = $arg;
             continue;
         }
     }
     if ($User === false) {
         throw new InvalidArgumentException("No or invalid user object provided");
     }
     if (!filter_var($User->id, FILTER_VALIDATE_INT)) {
         throw new InvalidArgumentException("It looks like you're not logged in");
     }
     if ($Image === false) {
         throw new InvalidArgumentException("No or invalid image object provided");
     }
     /**
      * If the author is the supplied user, get out
      */
     if (!isset($Image->author->User) || !$Image->author->User instanceof User) {
         $Image = ImageUpdater::updateAuthor($Image);
     }
     if ($Image->author->User instanceof User && $Image->author->User->id == $User->id || $Image->author->railpage_id == $User->id) {
         return;
     }
     /**
      * Insert into...on duplicate key update because feck it
      */
     $query = "INSERT INTO image_favourites (user_id, image_id, date) VALUES (%d, %d, NOW()) ON DUPLICATE KEY UPDATE date = VALUES(date)";
     $query = sprintf($query, $this->db->quote(intval($User->id)), $this->db->quote(intval($Image->id)));
     $this->db->query($query);
     return;
 }