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:
parent
ed2ba4e8e4
commit
4793d25c57
|
@ -61,5 +61,6 @@ foreach( $add as $propname){
|
||||||
$vcard->addProperty($propname, $value, $prop_parameters);
|
$vcard->addProperty($propname, $value, $prop_parameters);
|
||||||
}
|
}
|
||||||
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
|
$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);
|
OC_Contacts_App::renderDetails($id, $vcard);
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function contacts_namesort($a,$b){
|
|
||||||
return strcasecmp($a['fullname'],$b['fullname']);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once('../../../lib/base.php');
|
require_once('../../../lib/base.php');
|
||||||
OC_JSON::checkLoggedIn();
|
OC_JSON::checkLoggedIn();
|
||||||
OC_JSON::checkAppEnabled('contacts');
|
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());
|
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
|
||||||
$contacts = array();
|
$contacts = array();
|
||||||
foreach( $addressbooks as $addressbook ){
|
foreach( $addressbooks as $addressbook ){
|
||||||
|
@ -26,6 +26,7 @@ foreach( $addressbooks as $addressbook ){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usort($contacts,'contacts_namesort');
|
usort($contacts,'contacts_namesort');
|
||||||
|
*/
|
||||||
$tmpl = new OC_TEMPLATE("contacts", "part.contacts");
|
$tmpl = new OC_TEMPLATE("contacts", "part.contacts");
|
||||||
$tmpl->assign('contacts', $contacts);
|
$tmpl->assign('contacts', $contacts);
|
||||||
$page = $tmpl->fetchPage();
|
$page = $tmpl->fetchPage();
|
||||||
|
|
|
@ -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; }
|
#contacts li { padding-left:25px;background:url('../img/person.svg') no-repeat; }
|
||||||
#chooseaddressbook {margin-right: 170px; float: right;}
|
#chooseaddressbook {margin-right: 170px; float: right;}
|
||||||
#contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;}
|
#contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;}
|
||||||
|
|
|
@ -32,6 +32,9 @@ OC_Util::checkLoggedIn();
|
||||||
OC_Util::checkAppEnabled('contacts');
|
OC_Util::checkAppEnabled('contacts');
|
||||||
|
|
||||||
// Get active address books. This creates a default one if none exists.
|
// 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());
|
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
|
||||||
|
|
||||||
// Load the files we need
|
// Load the files we need
|
||||||
|
@ -39,7 +42,7 @@ OC_App::setActiveNavigationEntry( 'contacts_index' );
|
||||||
|
|
||||||
// Load a specific user?
|
// Load a specific user?
|
||||||
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;
|
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;
|
||||||
|
/*
|
||||||
// sort addressbooks (use contactsort)
|
// sort addressbooks (use contactsort)
|
||||||
usort($addressbooks,'contacts_namesort');
|
usort($addressbooks,'contacts_namesort');
|
||||||
|
|
||||||
|
@ -55,8 +58,10 @@ foreach( $addressbooks as $addressbook ){
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($contacts,'contacts_namesort');
|
usort($contacts,'contacts_namesort');
|
||||||
|
*/
|
||||||
$details = array();
|
$details = array();
|
||||||
|
|
||||||
|
// FIXME: This cannot work..?
|
||||||
if( !is_null($id)/* || count($contacts)*/){
|
if( !is_null($id)/* || count($contacts)*/){
|
||||||
if(is_null($id)) $id = $contacts[0]['id'];
|
if(is_null($id)) $id = $contacts[0]['id'];
|
||||||
$vcard = OC_Contacts_App::getContactVCard($id);
|
$vcard = OC_Contacts_App::getContactVCard($id);
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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! :)
|
|
@ -140,6 +140,25 @@ class OC_Contacts_Addressbook{
|
||||||
return true;
|
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.
|
* @brief Get active addressbooks for a user.
|
||||||
* @param integer $uid User id. If null current user will be used.
|
* @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){
|
public static function active($uid){
|
||||||
$active = self::activeIds($uid);
|
$active = self::activeIds($uid);
|
||||||
$addressbooks = array();
|
$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 ){
|
foreach( $active as $aid ){
|
||||||
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ? ORDER BY displayname' );
|
$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)]);
|
unset($openaddressbooks[array_search($id, $openaddressbooks)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$openaddressbooks = self::cleanArray($openaddressbooks, false);
|
||||||
sort($openaddressbooks, SORT_NUMERIC);
|
sort($openaddressbooks, SORT_NUMERIC);
|
||||||
// FIXME: I alway end up with a ';' prepending when imploding the array..?
|
// FIXME: I alway end up with a ';' prepending when imploding the array..?
|
||||||
OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',implode(';', $openaddressbooks));
|
OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',implode(';', $openaddressbooks));
|
||||||
|
@ -221,7 +242,7 @@ class OC_Contacts_Addressbook{
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function isActive($id){
|
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());
|
return in_array($id, self::activeIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,24 @@ class OC_Contacts_VCard{
|
||||||
* ['carddata']
|
* ['carddata']
|
||||||
*/
|
*/
|
||||||
public static function all($id){
|
public static function all($id){
|
||||||
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
|
//$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
|
||||||
$result = $stmt->execute(array($id));
|
//$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();
|
$cards = array();
|
||||||
while( $row = $result->fetchRow()){
|
while( $row = $result->fetchRow()){
|
||||||
$cards[] = $row;
|
$cards[] = $row;
|
||||||
|
|
Loading…
Reference in New Issue