method syncEmails documentation in bbn\User\Email

function(array $folder, int $limit = 0) { if (X::hasProps($folder, ['id', 'id_account', 'last_uid', 'uid'])) { $res = 0; $mb = $this->getMailbox($folder['id_account']); $info = $mb->getInfoFolder($folder['uid']); $mb->selectFolder($folder['uid']); if (!empty($folder['last_uid'])) { if ($folder['db_uid_max'] == $mb->getLastUid()) { return 0; } if (empty($start) and !empty($folder['db_uid_max'])) { $next = $mb->getNextUid($folder['db_uid_max']); if ($next != null) { $start = $mb->getMsgNo($next); } if (empty($start)) { $start = $mb->getMsgNo($folder['db_uid_max']); } } if (empty($start)) { $start = 1; } $real_end = $start + $limit; if ($real_end > $mb->getMsgNo($folder['last_uid'])) { $real_end = $mb->getMsgNo($folder['last_uid']); } $end = $start; $num = $real_end - $start; while ($end < $real_end) { $end = min($real_end, $start + 999); if ($all = $mb->getEmailsList($folder, $start, $real_end)) { $start += 1000; //var_dump($start, $end); foreach ($all as $a) { if ($this->insertEmail($folder, $a)) { $res++; } else { //throw new \Exception(X::_("Impossible to insert the email with ID").' '.$a['message_id']); $this->log(X::_("Impossible to insert the email with ID") . ' ' . $a['message_id']); } } if ($end === $real_end) { $hash = md5(json_encode(['numMsg' => $folder['num_msg'], 'lastUid' => $folder['last_uid']])); $this->pref->updateBit($folder['id'], [ 'last_check' => date('Y-m-d H:i:s'), 'hash' => $hash ], true); break; } } else { throw new \Exception( X::_("Impossible to get the emails for folder") . ' ' . $folder['uid'] . ' ' . X::_("from") . ' ' . $start . ' ' . X::_("to") . ' ' . $end . ' (' . $real_end . ')' ); } } } if ($info->Nmsgs > ($res + $folder['num_msg'])) { $cfg = $this->class_cfg['arch']['users_emails']; $table = $this->class_cfg['tables']['users_emails']; $num = $res + $folder['num_msg']; $s2 = 0; while ($info->Nmsgs < $num) { $msg = $this->db->rselect($table, [$cfg['id'], $cfg['msg_uid']], [$cfg['id_folder'] => $folder['id']], [$cfg['msg_uid'] => 'DESC'], $s2); if (!$mb->getMsgNo($msg['msg_uid'])) { if ($this->db->delete($table, [$cfg['id'] => $msg['id']])) { $num--; $s2--; } } $s2++; } } return $res; } return null; }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.