Qs_Db::getInstance()]))->getNotificationFiles($type, $id, $tribeIds))) { return false; } $firstFile = current($files); $vendorId = $vendorId ?: $firstFile['vendorId']; $vendorModel = new VendorModel(); if (!($to = $vendorModel->getUserEmails($vendorId))) { return false; } $placeholders = [ 'files' => self::renderFileList($files), ]; return Qs_Mail::sendTemplate('libraryNewFileToUser', $placeholders, $to); } protected static function renderFileList(array $files) { /** @var Qs_Doc $doc */ $doc = Zend_Registry::get('doc'); return $doc->fetchItem([ 'files' => self::prepareFileList($files), 'tpl' => 'Library/email-files.tpl', ]); } protected static function prepareFileList(array $files) { $result = []; foreach ($files as $file) { if (in_array($file['recordType'], [Obj::RECORD_TYPE_LICENSE, Obj::RECORD_TYPE_PREMIUM])) { $file['url'] = BASE_URL . '/' . $file['file']; } else { $file['url'] = Qs_FileFs::getUrl($file['file']); } if ($file['categoryId'] == AbstractObj::CATEGORY_ID_RFP) { $file['categoryUrl'] = Qs_SiteMap::findFirst(null, ['type' => 'Library\\Rfp\\'], null, 'url'); } else { $file['categoryUrl'] = View::getPage('url') . '/' . $file['categoryAlias']; } $result[$file['categoryId']][] = $file; } return $result; } }