Skip to content
This repository has been archived by the owner on Mar 1, 2018. It is now read-only.

Commit

Permalink
1.7 (close #9)
Browse files Browse the repository at this point in the history
  • Loading branch information
fs654 committed Dec 15, 2015
1 parent c335570 commit 3e1305e
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 10 deletions.
15 changes: 10 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.7.0:
- Added button to remove the cookie
- Added custom fbid option
- Profile picture with invalid fbid fixed

1.6.1:
- Big cleanup
- Unused vars removed (bug #8)
Expand Down Expand Up @@ -47,22 +52,22 @@
- Facebook connection status
- Status messages
- Prevent app access if not logged

1.1.0:
- Workaround for friends who have disabled the graph API
- Second auto match system using the Jaro-Winkler algorithm
- Various bug fixes
1.0.0:

1.0.0:
- More secure location for cookie (fixed #2)
- Massive Cleanup
- Fixed and improved login system
- Facebook friends now cached (better performances)
- Reorganized classes
- No more javascript data loading for the match section
- Sort contacts
0.1.8-alpha:

0.1.8-alpha:
- Fixed some css
- Cleanup

Expand Down
13 changes: 12 additions & 1 deletion app/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ public function setPhoto(){
"img" => $imgAltUrl,
"photo" => isset($this->vcard->PHOTO)
);
} else if($imgAltUrl == "notfound") {
return Array(
"error" => "Wrong FBID, User not found",
"id" => $this->id,
"name" => $this->getName(),
"backend" => $this->backend,
"addressbook" => $this->addressbook,
"img" => $imgAltUrl,
"photo" => isset($this->vcard->PHOTO)
);
} else {
$imgAlt = file_get_contents($imgAltUrl);
$image = new Image(base64_encode($imgAlt));
Expand Down Expand Up @@ -129,7 +139,8 @@ public function setPhoto(){
"name" => $this->getName(),
"backend" => $this->backend,
"addressbook" => $this->addressbook,
"photo" => isset($this->vcard->PHOTO)
"photo" => isset($this->vcard->PHOTO),
"alt_method" => isset($imgAltUrl)?$imgAltUrl:false
);
}
}
Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
['name' => 'page#match', 'url' => '/match', 'verb' => 'GET'],
['name' => 'page#sync', 'url' => '/sync', 'verb' => 'GET'],
['name' => 'facebook#login', 'url' => '/facebook/login', 'verb' => 'POST'],
['name' => 'facebook#delCookie', 'url' => '/facebook/delcookie', 'verb' => 'GET'],
['name' => 'facebook#reload', 'url' => '/facebook/reloadfriends', 'verb' => 'GET'],
['name' => 'facebook#islogged', 'url' => '/facebook/islogged', 'verb' => 'GET'],
['name' => 'contacts#perfectMatch', 'url' => '/perfectmatch', 'verb' => 'GET'],
Expand Down
11 changes: 11 additions & 0 deletions controller/facebookcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ public function getPicture_alt($fbid) {
}

$getdata = $this->dorequest("https://m.facebook.com/$fbid", false, true);
if (preg_match("/not found/mi", $getdata[1])) {
return "notfound";
}
if (empty($getdata[1])) {
return false;
}
Expand Down Expand Up @@ -342,6 +345,14 @@ public function islogged() {
public function login($email, $pass) {
return $this->fblogin(base64_decode($email), base64_decode($pass));
}

/**
* Login to facebook
* @NoAdminRequired
*/
public function delCookie() {
return unlink($this->userHome.$this->cookieName);
}

/**
* Force reload cache
Expand Down
12 changes: 10 additions & 2 deletions css/fbsync.css
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
padding-left: 10px;
margin-bottom: 10px;
}

/* ---- CONTACTS LIST ---- */
#contacts-list {
padding-top: 40px;
Expand All @@ -217,7 +218,6 @@
.localcontact {
margin: 10px;
transition: 300ms ease-in-out;
overflow: hidden;
display: inline-flex;
flex-grow: 0;
flex-shrink: 0;
Expand Down Expand Up @@ -252,10 +252,12 @@
border-left: none;
border-radius: 0 2px 2px 0;
width: 100%;
position: relative;
}
.localcontact .name {
width: 170px;
width: 155px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: block;
margin-bottom: 5px;
Expand All @@ -264,6 +266,12 @@
background-color: #3b5998;
color: #FFF;
}
.localcontact .custom_fbid {
position: absolute;
top: 5px;
right: 10px;
cursor: pointer;
}
.localcontact .selectspan {
display: inline-block;
width: 10px;
Expand Down
17 changes: 17 additions & 0 deletions js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ function logcheck() {
});

});


//---------- DELETE COOKIE ----------
$('#delcookie').click(function () {
var url = OC.generateUrl('apps/fbsync/facebook/delcookie');
$.get(url).success(function (response) {
if(response) {
jQuery('#app-settings-content #delcookie').css({'background-color':'#A1B56C','color':'white'});
alert("Cookie removed.")
} else {
jQuery('#app-settings-content #delcookie').css({'background-color':'#AB4642','color':'white'});
alert("Error while removing the cookie. Do you have the right permissions?")
}
});

});


//---------- LOGIN STATUS ----------
$.ajax({
Expand Down
30 changes: 30 additions & 0 deletions js/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,36 @@ function sortT(a,b){
reloadCache();
})

// Custom FBID button
$(".custom_fbid").click(function() {
// Fix for tooltip on disabled buttons
$('.tooltip').fadeOut();
// Update classes
var id=$(this).parent().parent().data('id');
var name=$(this).parent().find('.name').text();

var fbid = prompt("Enter fbid");
if (fbid != null && fbid == parseInt(fbid, 10) && !isNaN(fbid)) {
$(this).parent().parent().removeClass('nofbid');
updateFBID(id, fbid, function() {
var select = $('[data-id="'+id+'"] select');
var option = select.find('option[value='+fbid+']');
if(option.length>0) {
option.prop('selected',true);
} else {
select.find('.new_fbid').remove();
select.find('option:eq(0)').after('<option selected class="new_fbid" value="'+fbid+'">FBID not in your friends list</option>')
}
$('[data-id="'+id+'"] select').removeProp('disabled');
reloadMatched();
}, function() {
alert("Error saving "+name+" data !");
});
} else {
alert('Wrong input. FBIDs are supposed to be a number.')
}
})

// sort Alpha
$("#sortA").click(function() {
$(".localcontact").sort(sortA).appendTo($("#contacts-list"));
Expand Down
3 changes: 2 additions & 1 deletion templates/match.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
echo '<div class="content"><span class="name">';
echo $contact->getName();
echo '</span>';
echo '<div class="custom_fbid fa-pencil-square-o tooltipped" title="Custom FBID"></div>';
echo '<select class="fbselect">';
echo '<option value="false">Choose friend</option>';
// Building friends options
Expand All @@ -127,7 +128,7 @@
}
// If FBID not in friends list
if(isset($contact->vcard->FBID) && !$selected) {
$options = '<option selected value="'.$contact->getFBID().'">FBID not in your friends list</option>'.$options;
$options = '<option selected value="'.$contact->getFBID().'" class="new_fbid">FBID not in your friends list</option>'.$options;
}
echo $options;
echo '</select>';
Expand Down
5 changes: 4 additions & 1 deletion templates/part.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<div id="app-settings-content">
<i>Credentials</i><br>
<input type="text" id="fbemail" placeholder="User" /><br>
<input type="password" id="fbpass" placeholder="Password" /><input type="button" value="Login" id="fblogin" />
<input type="password" id="fbpass" placeholder="Password" />
<input type="button" value="Login"
title="Login will override previously stored credentials" class="tooltipped" id="fblogin" />
<button id="delcookie" class="fa-trash tooltipped" title="Remove stored credentials"></button>
</div>
</div>

0 comments on commit 3e1305e

Please sign in to comment.