Added license and waiver of conditions for jquery.inview.

CSS fix on contact list.
Query contacts from multiple address books.
This commit is contained in:
Thomas Tanghus 2011-12-30 21:07:16 +01:00
parent ed2ba4e8e4
commit 4793d25c57
8 changed files with 110 additions and 10 deletions

View File

@ -61,5 +61,6 @@ foreach( $add as $propname){
$vcard->addProperty($propname, $value, $prop_parameters);
}
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
OC_Log::write('contacts','ajax/addcard.php - adding id: '.$id,OC_Log::DEBUG);
OC_Contacts_App::renderDetails($id, $vcard);

View File

@ -6,14 +6,14 @@
* See the COPYING-README file.
*/
function contacts_namesort($a,$b){
return strcasecmp($a['fullname'],$b['fullname']);
}
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$ids = OC_Contacts_Addressbook::activeIds(OC_User::getUser());
$contacts = OC_Contacts_VCard::all($ids);
//OC_Log::write('contacts','contacts.php: '.count($contacts).' contacts.',OC_Log::DEBUG);
/*
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
$contacts = array();
foreach( $addressbooks as $addressbook ){
@ -26,6 +26,7 @@ foreach( $addressbooks as $addressbook ){
}
}
usort($contacts,'contacts_namesort');
*/
$tmpl = new OC_TEMPLATE("contacts", "part.contacts");
$tmpl->assign('contacts', $contacts);
$page = $tmpl->fetchPage();

View File

@ -1,3 +1,4 @@
#contacts { padding-left:5px; padding-top: 5px; background: #fff; }
#contacts li { padding-left:25px;background:url('../img/person.svg') no-repeat; }
#chooseaddressbook {margin-right: 170px; float: right;}
#contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;}

View File

@ -32,6 +32,9 @@ OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
// Get active address books. This creates a default one if none exists.
$ids = OC_Contacts_Addressbook::activeIds(OC_User::getUser());
$contacts = OC_Contacts_VCard::all($ids);
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
// Load the files we need
@ -39,7 +42,7 @@ OC_App::setActiveNavigationEntry( 'contacts_index' );
// Load a specific user?
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;
/*
// sort addressbooks (use contactsort)
usort($addressbooks,'contacts_namesort');
@ -55,8 +58,10 @@ foreach( $addressbooks as $addressbook ){
}
usort($contacts,'contacts_namesort');
*/
$details = array();
// FIXME: This cannot work..?
if( !is_null($id)/* || count($contacts)*/){
if(is_null($id)) $id = $contacts[0]['id'];
$vcard = OC_Contacts_App::getContactVCard($id);

View File

@ -0,0 +1,41 @@
Attribution-Non-Commercial-Share Alike 2.0 UK: England & Wales
http://creativecommons.org/licenses/by-nc-sa/2.0/uk/
You are free:
* to copy, distribute, display, and perform the work
* to make derivative works
Under the following conditions:
* Attribution — You must give the original author credit.
Attribute this work:
Information
What does "Attribute this work" mean?
The page you came from contained embedded licensing metadata,
including how the creator wishes to be attributed for re-use.
You can use the HTML here to cite the work. Doing so will
also include metadata on your page so that others can find the
original work as well.
* Non-Commercial — You may not use this work for commercial
purposes.
* Share Alike — If you alter, transform, or build upon this
work, you may distribute the resulting work only under a
licence identical to this one.
With the understanding that:
* Waiver — Any of the above conditions can be waived if you get
permission from the copyright holder.
* Other Rights — In no way are any of the following rights
affected by the license:
o Your fair dealing or fair use rights;
o The author's moral rights;
o Rights other persons may have either in the work itself
or in how the work is used, such as publicity or privacy rights.
* Notice — For any reuse or distribution, you must make clear to
others the licence terms of this work.

View File

@ -0,0 +1,15 @@
jQuery.inview is licensed Attribution-Non-Commercial-Share Alike 2.0 but the
conditions has been waived by the author in the following tweet:
https://twitter.com/#!/ChristopherBlum/status/148382899887013888
Saying:
Thomas Tanghus @tanghus 18 Dec. 2011
@ChristopherBlum Hi. Is it OK if I use https://github.com/protonet/jquery.inview in ownCloud? Preferably under an AGPL license ;-) owncloud.org
Christopher Blum Christopher Blum @ChristopherBlum 18 Dec. 2011
@tanghus Feel free to! :)

View File

@ -140,6 +140,25 @@ class OC_Contacts_Addressbook{
return true;
}
public static function cleanArray($array, $remove_null_number = true){
$new_array = array();
$null_exceptions = array();
foreach ($array as $key => $value){
$value = trim($value);
if($remove_null_number){
$null_exceptions[] = '0';
}
if(!in_array($value, $null_exceptions) && $value != "") {
$new_array[] = $value;
}
}
return $new_array;
}
/**
* @brief Get active addressbooks for a user.
* @param integer $uid User id. If null current user will be used.
@ -170,7 +189,8 @@ class OC_Contacts_Addressbook{
public static function active($uid){
$active = self::activeIds($uid);
$addressbooks = array();
/** FIXME: Is there a way to prepare a statement 'WHERE id IN ([range])'?
/* FIXME: Is there a way to prepare a statement 'WHERE id IN ([range])'?
* See OC_Contacts_VCard:all.
*/
foreach( $active as $aid ){
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ? ORDER BY displayname' );
@ -208,6 +228,7 @@ class OC_Contacts_Addressbook{
unset($openaddressbooks[array_search($id, $openaddressbooks)]);
}
}
$openaddressbooks = self::cleanArray($openaddressbooks, false);
sort($openaddressbooks, SORT_NUMERIC);
// FIXME: I alway end up with a ';' prepending when imploding the array..?
OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',implode(';', $openaddressbooks));
@ -221,7 +242,7 @@ class OC_Contacts_Addressbook{
* @return boolean
*/
public static function isActive($id){
OC_Log::write('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OC_Log::DEBUG);
//OC_Log::write('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OC_Log::DEBUG);
return in_array($id, self::activeIds());
}

View File

@ -47,9 +47,24 @@ class OC_Contacts_VCard{
* ['carddata']
*/
public static function all($id){
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
$result = $stmt->execute(array($id));
//$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
//$result = $stmt->execute(array($id));
if(is_array($id)) {
$id_sql = join(',', array_fill(0, count($id), '?'));
$prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname';
try {
$stmt = OC_DB::prepare( $prep );
$result = $stmt->execute($id);
} catch(Exception $e) {
OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG);
OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OC_Log::DEBUG);
OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG);
}
} else {
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
$result = $stmt->execute(array($id));
}
$cards = array();
while( $row = $result->fetchRow()){
$cards[] = $row;