public function noticePackageUploaded(Package $pkg) { $app = $this->app; $package_url = mfwRequest::makeURL("/package?id={$pkg->getId()}"); ob_start(); include APP_ROOT . '/data/notice_mail_template.php'; $body = ob_get_clean(); $addresses = array(); foreach ($this->rows as $r) { if ($r['notify']) { $addresses[] = $r['mail']; } } if (empty($addresses)) { return; } $subject = "New Package Uploaded to {$app->getTitle()}"; $sender = Config::get('mail_sender'); $to = $sender; $header = "From: {$sender}" . "\nBcc: " . implode(', ', $addresses); mb_language('uni'); mb_internal_encoding('UTF-8'); if (!mb_send_mail($to, $subject, $body, $header)) { throw new RuntimeException("mb_send_mail faild (pkg={$pkg->getId()}, {$pkg->getTitle()})"); } }
protected function makePackageArray(Package $pkg) { $tags = array(); foreach ($pkg->getTags() as $t) { $tags[] = $t->getName(); } return array('package_url' => mfwRequest::makeUrl("/package?id={$pkg->getId()}"), 'application_url' => mfwRequest::makeUrl("/app?id={$pkg->getAppId()}"), 'id' => $pkg->getId(), 'platform' => $pkg->getPlatform(), 'title' => $pkg->getTitle(), 'description' => $pkg->getDescription(), 'ios_identifier' => $pkg->getIOSIdentifier(), 'original_file_name' => $pkg->getOriginalFileName(), 'file_size' => $pkg->getFileSize(), 'created' => $pkg->getCreated(), 'tags' => $tags, 'install_count' => $pkg->getInstallCount()); }
public function testGetAndSetId() { $this->assertEquals(null, $this->sut->getId()); // XXX Doctrine uses reflection, so there's no other way // to unit test this $reflProp = new \ReflectionProperty('Terramar\\Packages\\Entity\\Remote', 'id'); $reflProp->setAccessible(true); $reflProp->setValue($this->sut, 345); $reflProp->setAccessible(false); $this->assertEquals(345, $this->sut->getId()); }
public function getPackageInstalledDate(Package $pkg, $format = null) { $appid = $pkg->getAppId(); if (!isset($this->pkg_install_dates[$appid])) { $this->pkg_install_dates[$appid] = InstallLog::packageInstalledDates($this, $appid); } if (!isset($this->pkg_install_dates[$appid][$pkg->getId()])) { return null; } $date = $this->pkg_install_dates[$appid][$pkg->getId()]; if ($format) { $date = date($format, strtotime($date)); } return $date; }
public static function getPackageInstallUsers(Package $pkg) { $sql = 'SELECT distinct(mail) FROM install_log WHERE package_id = ?'; $rows = mfwDBIBase::getAll($sql, array($pkg->getId())); $mails = array(); foreach ($rows as $r) { $mails[] = $r['mail']; } return $mails; }
/** * Get the package ID from database or create it in database * @param string $package * @return int */ private function getPackageId($package) { if ($package === null || trim($package) == '') { return null; } if (!isset($this->packageIds[$package])) { $this->packageIds[$package] = Package::getId($package); } return $this->packageIds[$package]; }
public static function removeFromPackage(Package $pkg, $con = null) { $sql = 'DELETE FROM package_tag WHERE package_id = ?'; mfwDBIBase::query($sql, array($pkg->getId()), $con); }