]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added license and waiver of conditions for jquery.inview.
authorThomas Tanghus <thomas@tanghus.net>
Fri, 30 Dec 2011 20:07:16 +0000 (21:07 +0100)
committerThomas Tanghus <thomas@tanghus.net>
Fri, 30 Dec 2011 20:07:16 +0000 (21:07 +0100)
CSS fix on contact list.
Query contacts from multiple address books.

apps/contacts/ajax/addcard.php
apps/contacts/ajax/contacts.php
apps/contacts/css/styles.css
apps/contacts/index.php
apps/contacts/js/LICENSE.jquery.inview [new file with mode: 0644]
apps/contacts/js/jquery.inview.txt [new file with mode: 0644]
apps/contacts/lib/addressbook.php
apps/contacts/lib/vcard.php

index 9d782246a0acec2fbcb657e94493be959a136827..54c455e515f8688747b6df1677f5120b9ab14069 100644 (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);
index b34cf41424994725e8ce6c7b74eb7561b756bda2..54ad3e4c1030aa41271bb9057172537e5501ac65 100644 (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();
index b6709c5a7912cef45e73cb90c689cd2f4ac12e1f..53b469e6eed96f51f25273d0c8021b8f8dee3421 100644 (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%;}
index a6af54c8789e757716eb73dc10c1cf4a796aba04..5ab6f293ab4527b413f9e2f7d57eece91c95fa2a 100644 (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);
diff --git a/apps/contacts/js/LICENSE.jquery.inview b/apps/contacts/js/LICENSE.jquery.inview
new file mode 100644 (file)
index 0000000..1ed340e
--- /dev/null
@@ -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.
+
diff --git a/apps/contacts/js/jquery.inview.txt b/apps/contacts/js/jquery.inview.txt
new file mode 100644 (file)
index 0000000..c53dbd1
--- /dev/null
@@ -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! :)
index 6f2f34225de755d7ba75dd224b65c659b3060ef8..b3c981a541e9acb43908ff3bdc40184b59a33bd2 100644 (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());
        }
 
index 7285761fd58706ded153162076d2b8d254c1945f..81519b3d051842b9b163250a0edf4f1fa1c42b64 100644 (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;