QR-Code Support #5030

Closed
rcubetrac opened this Issue May 26, 2011 · 6 comments

Projects

None yet

3 participants

@rcubetrac

Reported by lacri on 26 May 2011 07:06 UTC as Trac ticket #1487936

a nice Feature for the Roundcube Addressbook are QR-Code Support ... Display in Addressbook for every User the vcard without photo as QR-Code so can users add quickly with a mobile phone eg android or iphone contacts to the mobile phone. A other nice place for QR-Code is send optional as attachment like as vcard.

See http://en.wikipedia.org/wiki/QR_code
http://phpqrcode.sourceforge.net/
http://code.google.com/intl/de-DE/apis/chart/image/docs/gallery/qr_codes.html

Migrated-From: http://trac.roundcube.net/ticket/1487936

@rcubetrac

Comment by @thomascube on 26 May 2011 10:14 UTC

And what exactly is the data format to be encoded in such a QR-code? What do these mobile apps expect? A complete Vcard or just some delimited values? Please add more information.

@rcubetrac

Comment by @thomascube on 26 May 2011 10:17 UTC

OK, I've found something: MECARD spec[[BR]]

That would result in something like

MECARD:N:Owen,Sean;ADR:76 9th Avenue, 4th Floor, New York, NY 10011;TEL:+12125551212;EMAIL:srowen@example.com;;

or

BIZCARD:N:Sean;X:Owen;T:Software Engineer;C:Google;A:76 9th Avenue, New York, NY 10011;B:+12125551212;E:srowen@google.com;; 
@rcubetrac

Comment by lacri on 26 May 2011 10:41 UTC

MECARD and BIZCARD is not releated to QR-Code
The best solution is a complete vCard in QR-Code format (picture) all new and modern devices with google android or apple ios support this Blackberry or Nokia Devices Support this with extra Software eg. i-nigma.

The Only limitation is the vCard Size so we can not add user picture in code.

i have implement QR-Code in my compose.inc so add my vcard as qr-code attachment i will send you an email from my solution.

function rcmail_attach_vcard()
{
  global $USER, $DB, $CONFIG, $COMPOSE_ID;

  $ret = false;
  $sql_result = $USER->list_identities_from();
  $att_file = "";

  if (isset($_POST[{
    $iid = trim($_POST['iid']('iid']))));
  }
  else {
    $standard = true;
  }

  if ($sql_result) {
    foreach ($sql_result as $sql_key => $sql_arr) {
      if($standard)
        $search = ($sql_arr[== true);
      else
        $search = ($sql_arr['identity_id']('standard_from']) == $iid);

      if($sql_arr[== true && $search) {
        foreach($sql_arr as $key => $val)
          $sql_arr[$key]('vcard']) = utf8_decode($val);

        $vcard = new rcube_vcard();
        list($firstname,$surname) = split(' ', $sql_arr[       $vcard->set('displayname', $sql_arr['name']('name']);
));
        $vcard->set('firstname', $firstname);
        $vcard->set('surname', $surname);
        if(!empty($sql_arr[{
          $vcard->set('organization', $sql_arr['organization']('organization']))));
        }
        $temparr = array();
        if($sql_arr[!= "")
          $temparr[]('reply-to']) = $sql_arr[       $temparr[]('reply-to'];
) = $sql_arr[       $vcard->set('email', $temparr);
        $temp = str_replace("\\;",";",$vcard->export());
        $temp = str_replace("\\:",":",$temp);

        $temparr = rcube_vcard::import($temp);
        if(is_array($temparr)) {
          foreach($temparr[0]('email'];
)->email as $key => $val) {
            if(is_array($val)) {
              $count = count($val);
              $i = 0;
              foreach($val as $key1 => $email) {
                $i++;
                if($email != "" && $i < $count) {
                  $temp = str_replace($email .";","",$temp);
                  $temp = str_replace("END:VCARD","EMAIL;type=INTERNET;:" . $email . "\nEND:VCARD",$temp);
                }
              }
            }
          }
        }
        $att_file = $_SESSION[. ".vcf";

        if(@file_put_contents($CONFIG['temp_dir']('username']) . '/' . $att_file, $temp)) {
          $ret = 'vcard.vcf';
          $attachment = array(
                  'path' => $CONFIG[. '/' . $att_file,
                  'name' => $ret,
                  'mimetype' => 'text/x-vcard',
            'group' => $COMPOSE_ID,
              );

          $attachment = rcmail::get_instance()->plugins->exec_hook('attachment_upload', $attachment);
            if ($attachment['status']('temp_dir'])) {
              $id = $attachment[           // store new attachment in session
              unset($attachment['status']('id'];
));
              $_SESSION[= $attachment;
              $_SESSION['vcf_idx']('compose']['attachments'][$id]) = count ($_SESSION[- 1;
          }

        include INSTALL_PATH . 'program/lib/phpqrcode/qrlib.php';
        $qrcode_file = $_SESSION['username']('compose']['attachments'])) . ".png";      
        $file_new = QRcode::png($temp, $CONFIG[. '/' . $qrcode_file);


          $qrret = 'qr-code_vcard.png';
          $qrattachment = array(
                  'path' => $CONFIG['temp_dir']('temp_dir']) . '/' . $qrcode_file,
                  'name' => $qrret,
                  'mimetype' => 'image/png',
            'group' => $COMPOSE_ID,
              );

          $qrattachment = rcmail::get_instance()->plugins->exec_hook('attachment_upload', $qrattachment);
            if ($qrattachment[{
              $qrid = $qrattachment['id']('status']));
            // store new attachment in session
              unset($qrattachment[            $_SESSION['compose']('status']);
)[= $qrattachment;
              $_SESSION['vcf_idx']('attachments'][$qrid]) = count ($_SESSION['compose']['attachments']) - 1;
          }
        }        
        break;
      }
    }
  }
  return $ret;
}
@rcubetrac rcubetrac added this to the later milestone Mar 20, 2016
@alecpl alecpl self-assigned this Dec 11, 2016
@alecpl alecpl modified the milestone: 1.3-beta, later Dec 11, 2016
@alecpl
Member
alecpl commented Dec 11, 2016

Implemented.

@alecpl alecpl closed this Dec 11, 2016
@Takika
Contributor
Takika commented Dec 11, 2016

I also done this with the same library as a plugin for myself :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment