Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from tuyennn/develop
Browse files Browse the repository at this point in the history
Bump version to 1.1.6
  • Loading branch information
tuyennn authored May 26, 2019
2 parents 5a1f114 + cf8e589 commit 7b1cefa
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 39 deletions.
32 changes: 16 additions & 16 deletions Model/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ public function getv2Inbox()
*/
public function getUserTags($usernameId)
{
$tags = $this->request("usertags/$usernameId/feed/?rank_token=$this->rank_token&ranked_content=true&")[1];
$tags = $this->request("usertags/$usernameId/feed/?rank_token=$this->rankToken&ranked_content=true&")[1];

if ($tags['status'] !== 'ok') {
throw new \Exception($tags['message'] . "\n");
Expand Down Expand Up @@ -1059,7 +1059,7 @@ public function getSelfUserTags()

public function tagFeed($tag)
{
$userFeed = $this->request("feed/tag/$tag/?rank_token=$this->rank_token&ranked_content=true&")[1];
$userFeed = $this->request("feed/tag/$tag/?rank_token=$this->rankToken&ranked_content=true&")[1];

if ($userFeed['status'] !== 'ok') {
throw new \Exception($userFeed['message'] . "\n");
Expand Down Expand Up @@ -1136,7 +1136,7 @@ public function getSelfGeoMedia()
public function fbUserSearch($query)
{
$query = rawurlencode($query);
$query = $this->request("fbsearch/topsearch/?context=blended&query=$query&rank_token=$this->rank_token")[1];
$query = $this->request("fbsearch/topsearch/?context=blended&query=$query&rank_token=$this->rankToken")[1];

if ($query['status'] !== 'ok') {
throw new \Exception($query['message'] . "\n");
Expand All @@ -1158,7 +1158,7 @@ public function fbUserSearch($query)
*/
public function searchUsers($query)
{
$query = $this->request('users/search/?ig_sig_key_version=' . self::SIG_KEY_VERSION . "&is_typeahead=true&query=$query&rank_token=$this->rank_token")[1];
$query = $this->request('users/search/?ig_sig_key_version=' . self::SIG_KEY_VERSION . "&is_typeahead=true&query=$query&rank_token=$this->rankToken")[1];

if ($query['status'] !== 'ok') {
throw new \Exception($query['message'] . "\n");
Expand Down Expand Up @@ -1218,7 +1218,7 @@ public function syncFromAdressBook($contacts)
*/
public function searchTags($query)
{
$query = $this->request("tags/search/?is_typeahead=true&q=$query&rank_token=$this->rank_token")[1];
$query = $this->request("tags/search/?is_typeahead=true&q=$query&rank_token=$this->rankToken")[1];

if ($query['status'] !== 'ok') {
throw new \Exception($query['message'] . "\n");
Expand All @@ -1239,7 +1239,7 @@ public function searchTags($query)
public function getTimeline($maxid = null)
{
$timeline = $this->request(
"feed/timeline/?rank_token=$this->rank_token&ranked_content=true"
"feed/timeline/?rank_token=$this->rankToken&ranked_content=true"
. (!is_null($maxid) ? "&max_id=" . $maxid : '')
)[1];

Expand Down Expand Up @@ -1267,7 +1267,7 @@ public function getTimeline($maxid = null)
public function getUserFeed($usernameId, $maxid = null, $minTimestamp = null)
{
$userFeed = $this->request(
"feed/user/$usernameId/?rank_token=$this->rank_token"
"feed/user/$usernameId/?rank_token=$this->rankToken"
. (!is_null($maxid) ? "&max_id=" . $maxid : '')
. (!is_null($minTimestamp) ? "&min_timestamp=" . $minTimestamp : '')
. "&ranked_content=true"
Expand Down Expand Up @@ -1295,9 +1295,9 @@ public function getUserFeed($usernameId, $maxid = null, $minTimestamp = null)
public function getHashtagFeed($hashtagString, $maxid = null)
{
if (is_null($maxid)) {
$endpoint = "feed/tag/$hashtagString/?rank_token=$this->rank_token&ranked_content=true&";
$endpoint = "feed/tag/$hashtagString/?rank_token=$this->rankToken&ranked_content=true&";
} else {
$endpoint = "feed/tag/$hashtagString/?max_id=" . $maxid . "&rank_token=$this->rank_token&ranked_content=true&";
$endpoint = "feed/tag/$hashtagString/?max_id=" . $maxid . "&rank_token=$this->rankToken&ranked_content=true&";
}

$hashtagFeed = $this->request($endpoint)[1];
Expand All @@ -1324,7 +1324,7 @@ public function getHashtagFeed($hashtagString, $maxid = null)
public function searchLocation($query)
{
$query = rawurlencode($query);
$endpoint = "fbsearch/places/?rank_token=$this->rank_token&query=" . $query;
$endpoint = "fbsearch/places/?rank_token=$this->rankToken&query=" . $query;

$locationFeed = $this->request($endpoint)[1];

Expand All @@ -1350,9 +1350,9 @@ public function searchLocation($query)
public function getLocationFeed($locationId, $maxid = null)
{
if (is_null($maxid)) {
$endpoint = "feed/location/$locationId/?rank_token=$this->rank_token&ranked_content=true&";
$endpoint = "feed/location/$locationId/?rank_token=$this->rankToken&ranked_content=true&";
} else {
$endpoint = "feed/location/$locationId/?max_id=" . $maxid . "&rank_token=$this->rank_token&ranked_content=true&";
$endpoint = "feed/location/$locationId/?max_id=" . $maxid . "&rank_token=$this->rankToken&ranked_content=true&";
}

$locationFeed = $this->request($endpoint)[1];
Expand Down Expand Up @@ -1386,7 +1386,7 @@ public function getSelfUserFeed()
*/
public function getPopularFeed()
{
$popularFeed = $this->request("feed/popular/?people_teaser_supported=1&rank_token=$this->rank_token&ranked_content=true&")[1];
$popularFeed = $this->request("feed/popular/?people_teaser_supported=1&rank_token=$this->rankToken&ranked_content=true&")[1];

if ($popularFeed['status'] !== 'ok') {
throw new \Exception($popularFeed['message'] . "\n");
Expand All @@ -1408,7 +1408,7 @@ public function getPopularFeed()
*/
public function getUserFollowings($usernameId, $maxid = null)
{
return $this->request("friendships/$usernameId/following/?max_id=$maxid&ig_sig_key_version=" . self::SIG_KEY_VERSION . "&rank_token=$this->rank_token")[1];
return $this->request("friendships/$usernameId/following/?max_id=$maxid&ig_sig_key_version=" . self::SIG_KEY_VERSION . "&rank_token=$this->rankToken")[1];
}

/**
Expand All @@ -1422,7 +1422,7 @@ public function getUserFollowings($usernameId, $maxid = null)
*/
public function getUserFollowers($usernameId, $maxid = null)
{
return $this->request("friendships/$usernameId/followers/?max_id=$maxid&ig_sig_key_version=" . self::SIG_KEY_VERSION . "&rank_token=$this->rank_token")[1];
return $this->request("friendships/$usernameId/followers/?max_id=$maxid&ig_sig_key_version=" . self::SIG_KEY_VERSION . "&rank_token=$this->rankToken")[1];
}

/**
Expand All @@ -1444,7 +1444,7 @@ public function getSelfUserFollowers()
*/
public function getSelfUsersFollowing()
{
return $this->request('friendships/following/?ig_sig_key_version=' . self::SIG_KEY_VERSION . "&rank_token=$this->rank_token")[1];
return $this->request('friendships/following/?ig_sig_key_version=' . self::SIG_KEY_VERSION . "&rank_token=$this->rankToken")[1];
}

/**
Expand Down
63 changes: 63 additions & 0 deletions Plugin/Ui/DataProvider/Product/DataProviderPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace GhoSter\AutoInstagramPost\Plugin\Ui\DataProvider\Product;

use Magento\Framework\DB\Select;
use Magento\Framework\Api\Filter;
use GhoSter\AutoInstagramPost\Ui\DataProvider\Product\DataProvider;

/**
* Class DataProviderPlugin
* @package GhoSter\AutoInstagramPost\Plugin\Ui\DataProvider\Product
*/
class DataProviderPlugin
{
/**
* @param DataProvider $subject
* @param callable $proceed
* @param Filter $filter
* @throws \Zend_Db_Select_Exception
*/
public function aroundAddFilter(
DataProvider $subject,
callable $proceed,
Filter $filter
) {

$proceed($filter);

if ($filter->getField() == 'posted_to_instagram') {
$collection = $subject->getCollection();
$select = $collection->getSelect();
$partsFrom = $select->getPart(Select::FROM);

if (isset($partsFrom['at_posted_to_instagram'])) {
if ($whereParts = $select->getPart(Select::WHERE)) {
foreach ($whereParts as $key => $wherePartItem) {
$whereParts[$key] = $this->_replaceFilterCondition($wherePartItem);
}
$select->setPart(Select::WHERE, $whereParts);
}
}
}
}

/**
* Replace table alias in condition string
*
* @param string|null $conditionString
* @return string|null
*/
protected function _replaceFilterCondition($conditionString)
{
if ($conditionString === null) {
return null;
}

if ($conditionString == "(at_posted_to_instagram.value = '0')") {
$conditionString = "(at_posted_to_instagram.value = '0' OR at_posted_to_instagram.value IS NULL)";
}

return $conditionString;
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This Magento 2 extension Auto Instagram Post allows you add your products immedi
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bf0757d0063e489eb3bff2479964fce2)](https://www.codacy.com/app/GhoSterInc/AutoInstagramPost?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=tuyennn/AutoInstagramPost&amp;utm_campaign=Badge_Grade)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/thinghost)
![Version 1.1.5](https://img.shields.io/badge/Version-1.1.5-green.svg)
![Version 1.1.5](https://img.shields.io/badge/Version-1.1.6-green.svg)

---
## [![Alt GhoSter](http://thinghost.info/wp-content/uploads/2015/12/ghoster.png "thinghost.info")](http://thinghost.info) Overview
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

},
"type": "magento2-module",
"version": "1.1.5",
"version": "1.1.6",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
3 changes: 3 additions & 0 deletions etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@
<type name="Magento\Backend\Model\Menu\Builder">
<plugin name="GhoSter_AutoInstagramPost::disable_manage_menu_depends_module_status" type="GhoSter\AutoInstagramPost\Plugin\Model\Menu\BuilderPlugin"/>
</type>
<type name="GhoSter\AutoInstagramPost\Ui\DataProvider\Product\DataProvider">
<plugin name="GhoSter_AutoInstagramPost::fix_filter_ui_component_boolean" type="GhoSter\AutoInstagramPost\Plugin\Ui\DataProvider\Product\DataProviderPlugin"/>
</type>
</config>
40 changes: 20 additions & 20 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
<resource>GhoSter_AutoInstagramPost::config</resource>
<group id="general" translate="label" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>General Settings</label>
<field id="enable" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enable Auto Instagram</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="username" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Username(Instagram Account)</label>
<frontend_class>required-entry</frontend_class>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
<validate>required-entry</validate>
</field>
<field id="password" translate="label" type="password" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Password</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
<validate>required-entry</validate>
</field>
Expand All @@ -35,7 +35,7 @@
<label/>
<comment><![CDATA[This action will try to use your provided data to login with Instagram API]]></comment>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
</field>
<field id="upload_image_id" translate="label comment" type="image" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
Expand All @@ -44,51 +44,51 @@
<base_url type="media" scope_info="1">instagram</base_url>
<comment><![CDATA[Default Image will be uploaded when product have no Image available. Recommended 800x800 px]]></comment>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
<validate>required-entry</validate>
</field>
<field id="enable_observer" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Allow auto posting to Instagram after Saving Product</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
</field>
</group>
<group id="comment_hashtag" translate="label" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Images Description Settings</label>
<field id="enable" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="enabled" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enable Auto Hashtag and Description</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="*/general/enable">1</field>
<field id="*/general/enabled">1</field>
</depends>
</field>
<field id="product_description" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Add Product Description to Post</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Description on Instagram Post should be generated from product description]]></comment>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
</depends>
</field>
<field id="category_hashtag" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Add Categories Name as Hashtags</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Hashtag on Instagram Post should be generated from categories which product belongs]]></comment>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
</depends>
</field>
<field id="enable_custom" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Add Custom Hashtags</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
</depends>
</field>
<field id="hashtag" translate="label" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
Expand All @@ -97,17 +97,17 @@
<backend_model>GhoSter\AutoInstagramPost\Model\Config\Backend\Hashtag</backend_model>
<comment><![CDATA[Hashtag on Instagram Post should include these custom, no need to add # before hashtag, value should be stripped and remove spaces]]></comment>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
<field id="enable_custom">1</field>
</depends>
</field>
<field id="description_template" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Description Template</label>
<comment><![CDATA[{{CUSTOMHASTAG}} {{CATEGORYHASHTAG}} {{PRODUCTDESC}} {{PRODUCTNAME}}</br>Instagram caption character limit: 2,200 characters</br>Instagram hashtag limit: 30 hashtags</br>Instagram bio character limit: 150 characters]]></comment>
<depends>
<field id="*/general/enable">1</field>
<field id="enable">1</field>
<field id="*/general/enabled">1</field>
<field id="enabled">1</field>
</depends>
</field>
</group>
Expand All @@ -117,7 +117,7 @@
<label>Enable Scheduled Auto Post</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="*/general/enable">1</field>
<field id="*/general/enabled">1</field>
</depends>
</field>
<field id="time" translate="label" type="time" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
Expand All @@ -137,7 +137,7 @@
<field id="limit" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Limit Number of Posts</label>
<depends>
<field id="enable">1</field>
<field id="enabled">1</field>
</depends>
<validate>validate-zero-or-greater</validate>
</field>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="GhoSter_AutoInstagramPost" setup_version="1.1.5"/>
<module name="GhoSter_AutoInstagramPost" setup_version="1.1.6"/>
</config>

0 comments on commit 7b1cefa

Please sign in to comment.