Ejemplo n.º 1
0
 public function saveAlbumData($albumID, $userID, $albumOld, $fields, $extra = array())
 {
     // Is this a new album?
     if (!$albumID) {
         $extra['post_date'] = date_helper::now();
     }
     // Do we have user id?
     if ($userID) {
         $extra['user_id'] = $userID;
     }
     // Save album
     if (!($newAlbumID = $this->fields_model->saveValues('picture_album', $albumID, $albumOld, $fields, $extra))) {
         return 0;
     }
     // Update counters
     if ($userID) {
         // Is this a new album?
         if (!$albumID) {
             $this->db->query("UPDATE `:prefix:users` SET `total_albums`=`total_albums`+1 WHERE `user_id`=? LIMIT 1", array($userID));
         }
     }
     // Did we add a new album or privacy setting changed?
     if (!$albumID || $extra['privacy'] != $albumOld['privacy']) {
         // Clean up counters
         $this->counters_model->deleteCounters('user', $albumID ? $albumOld['user_id'] : $userID);
     }
     if ($albumID) {
         // Update timeline action
         timeline_helper::update(true, 'picture_post', $albumOld['user_id'], $newAlbumID, false, $extra['privacy']);
         // Action hook
         hook::action('pictures/albums/update', $newAlbumID, $extra);
     } else {
         // Action hook
         hook::action('pictures/albums/insert', $newAlbumID, $extra);
     }
     return $newAlbumID;
 }
Ejemplo n.º 2
0
 public function toggleAdStatus($adID, $userID, $ad, $status = 1)
 {
     // Are you trying to assign the same status?
     if ($ad['active'] == $status) {
         return true;
     }
     // Update status
     $this->db->query("UPDATE `:prefix:classifieds_data` SET `active`=? WHERE `ad_id`=? LIMIT 1", array($status, $adID));
     // Update counters
     if ($status == 1) {
         $this->db->query("UPDATE `:prefix:users` SET `total_classifieds`=`total_classifieds`+1, `total_classifieds_i`=`total_classifieds_i`-1 WHERE `user_id`=? LIMIT 1", array($userID));
     } elseif ($ad['active'] != 9) {
         $this->db->query("UPDATE `:prefix:users` SET `total_classifieds`=`total_classifieds`-1, `total_classifieds_i`=`total_classifieds_i`+1 WHERE `user_id`=? LIMIT 1", array($userID));
     }
     // Update timeline action
     timeline_helper::update(true, 'classified_ad_post', $ad['user_id'], $adID, $status);
     // Action hook
     hook::action('classifieds/status/update', $adID, $status);
     // Clean up counters
     $this->counters_model->deleteCounters('user', $userID);
     return true;
 }
Ejemplo n.º 3
0
 public function togglePictureStatus($pictureID, $albumID, $userID, $picture, $album, $status = 1)
 {
     // Are you trying to assign the same status?
     if ($picture['active'] == $status) {
         return true;
     }
     // Update status
     $this->db->query("UPDATE `:prefix:pictures_data` SET `active`=? WHERE `picture_id`=? LIMIT 1", array($status, $pictureID));
     // Update counters
     if ($status == 1) {
         $this->db->query("UPDATE `:prefix:pictures_albums_data` SET `total_pictures`=`total_pictures`+1, `total_pictures_i`=`total_pictures_i`-1 WHERE `album_id`=? LIMIT 1", array($albumID));
         $this->db->query("UPDATE `:prefix:users` SET `total_pictures`=`total_pictures`+1, `total_pictures_i`=`total_pictures_i`-1 WHERE `user_id`=? LIMIT 1", array($userID));
     } elseif ($picture['active'] != 9) {
         $this->db->query("UPDATE `:prefix:pictures_albums_data` SET `total_pictures`=`total_pictures`-1, `total_pictures_i`=`total_pictures_i`+1 WHERE `album_id`=? LIMIT 1", array($albumID));
         $this->db->query("UPDATE `:prefix:users` SET `total_pictures`=`total_pictures`-1, `total_pictures_i`=`total_pictures_i`+1 WHERE `user_id`=? LIMIT 1", array($userID));
     }
     // Update timeline action
     timeline_helper::update(true, 'picture_post', $userID, $albumID, $status);
     // Action hook
     hook::action('pictures/status/update', $pictureID, $albumID, $status);
     return true;
 }
Ejemplo n.º 4
0
 public function toggleVerifiedStatus($userID, $user, $status = 1)
 {
     // Are you trying to assign the same status?
     if ($user['verified'] == $status) {
         return false;
     }
     // Update status
     $this->db->query("UPDATE `:prefix:users` SET `verified`=? WHERE `user_id`=? LIMIT 1", array($status, $userID));
     // Update timeline action
     timeline_helper::update(true, 'user_signup', $userID, $userID, isset($user['active']) && $user['active'] && $status ? 1 : 0);
     // Action hook
     hook::action('users/verified/' . ($status ? 'approve' : 'decline'), $userID);
     return true;
 }