Skip to content

Commit

Permalink
Update for publish on Instafgram and Facebook
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Dec 17, 2024
1 parent 8d809be commit 342ee18
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 68 deletions.
8 changes: 4 additions & 4 deletions objects/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ abstract class ObjectYPT implements ObjectInterface
protected $id;
protected $created;

public function __construct($id = "")
public function __construct($id = "", $refreshCache = false)
{
if (!empty($id)) {
// get data from id
$this->load($id);
$this->load($id, $refreshCache);
}
}

Expand All @@ -29,9 +29,9 @@ public static function getSearchFieldsNames()
return [];
}

public function load($id)
public function load($id, $refreshCache = false)
{
$row = self::getFromDb($id);
$row = self::getFromDb($id, $refreshCache);
if (empty($row)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion objects/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function __construct($id, $name = '')
}
}

public function load($id)
public function load($id, $refreshCache = false)
{
$row = self::getCategory($id);
if (empty($row)) {
Expand Down
2 changes: 1 addition & 1 deletion objects/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getVideos_id() {
return $this->videos_id;
}

public function load($id) {
public function load($id, $refreshCache = false) {
$row = self::getComment($id);
if (empty($row)) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions objects/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public function __construct($video_resolution = "")
}
}

public function load($id='')
public function load($id='', $refreshCache = false)
{
global $global;
return parent::load(1);
return parent::load(1, $refreshCache);
}

public function save(){
Expand Down
2 changes: 1 addition & 1 deletion objects/subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct($id, $email = "", $user_id = "", $subscriber_users_i
}
}

public function load($id)
public function load($id, $refreshCache = false)
{
$obj = self::getSubscribe($id);
if (empty($obj)) {
Expand Down
2 changes: 1 addition & 1 deletion objects/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function getExternalOption($id)
return $eo[$id];
}

public function load($id)
public function load($id, $refreshCache = false)
{
$id = intval($id);
if (empty($id)) {
Expand Down
2 changes: 1 addition & 1 deletion objects/userGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct($id, $group_name = "")
}
}

public function load($id)
public function load($id, $refreshCache = false)
{
$user = self::getUserGroupsDb($id);
if (empty($user)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ class Publisher_video_publisher_logs extends ObjectYPT
protected $id, $publish_datetimestamp, $status, $details, $videos_id, $users_id,
$publisher_social_medias_id, $timezone;

const STATUS_UNVERIFIED = 'u';
const STATUS_VERIFIED = 'v';
const STATUS_ACTIVE = 'a';
const STATUS_INACTIVE = 'i';
const STATUS_PROCESSING = 'p';

static function getSearchFieldsNames()
{
return array('details', 'timezone');
Expand Down Expand Up @@ -199,6 +205,7 @@ public static function getAllFromVideosId($videos_id)

static function getInfo($row)
{
global $global;

$row['publish'] = date('Y-m-d H:i:s', $row['publish_datetimestamp']);
$row['json'] = json_decode($row['details']);
Expand Down Expand Up @@ -229,6 +236,18 @@ static function getInfo($row)
$link = "https://www.facebook.com/watch/?v=" . $row['json']->response->VideoUploadResponse->id;
$msg[] = "<a href='{$link}' target='_blank'>{$link}</a>";
}
break;
case SocialMediaPublisher::SOCIAL_TYPE_INSTAGRAM["name"]:
if(!empty($row['json']->mediaResponse->permalink)){
$msg[] = "<a href='{$row['json']->mediaResponse->permalink}' target='_blank'>{$row['json']->mediaResponse->permalink}</a>";
}else if ($row['status'] === self::STATUS_UNVERIFIED) {
$msg[] = '<i class="fa fa-spinner fa-spin"></i> <strong>Video is being processed:</strong> Your video is currently being processed for publishing on Instagram. Please wait.';
} elseif ($row['status'] === self::STATUS_VERIFIED) {
$msg[] = '<i class="fa fa-check-circle"></i> <strong>Video successfully published:</strong> Your video has been verified and uploaded to Instagram.';
} else {
$msg[] = '<i class="fa fa-exclamation-triangle"></i> <strong>status:</strong> ' . $row['status'] . '';
}

break;
}
$row['msg'] = implode('<br>', $msg);
Expand All @@ -251,4 +270,12 @@ public static function getTotalFromVideosId($videos_id)
sqlDAL::close($res);
return $countRow;
}

public function save()
{
if (empty($this->status)) {
$this->status = self::STATUS_UNVERIFIED;
}
return parent::save();
}
}
Loading

0 comments on commit 342ee18

Please sign in to comment.