public function getAppInstallDate(Application $app, $format = null) { $install_apps = $this->getInstallApps(); if (isset($install_apps[$app->getId()])) { return $install_apps[$app->getId()]->getLastInstalled(); } return null; }
/** * Check if a page has any answers associated with it for a specific application * @param Page $page * @param Application $application * @return boolean */ public function hasApplicationAnswers(Page $page, Application $application) { $query = $this->_em->createQuery('SELECT COUNT(answer.id) as ancnt FROM Jazzee\\Entity\\Answer answer JOIN answer.applicant applicant WHERE answer.page = :pageId AND applicant.application = :applicationId'); $query->setParameter('pageId', $page->getId()); $query->setParameter('applicationId', $application->getId()); $result = $query->getResult(); return $result[0]['ancnt'] > 0; }
/** * Get the navigation * @return Navigation */ public function getNavigation() { if (empty($this->program) and empty($this->application)) { return null; } $navigation = new \Foundation\Navigation\Container(); $menu = new \Foundation\Navigation\Menu(); $menu->setTitle('Navigation'); if (empty($this->application)) { $link = new \Foundation\Navigation\Link('Welcome'); $link->setHref($this->path('apply')); $menu->addLink($link); } else { $path = 'apply/' . $this->program->getShortName() . '/' . $this->cycle->getName(); $link = new \Foundation\Navigation\Link('Welcome'); $link->setHref($this->path($path)); $link->setCurrent(true); $menu->addLink($link); //Only show the other cycles link if there are other published visible cycles $applications = $this->_em->getRepository('Jazzee\\Entity\\Application')->findByProgram($this->program, false, true, array($this->application->getId())); if (count($applications) > 0) { $link = new \Foundation\Navigation\Link('Other Cycles'); $link->setHref($this->path('apply/' . $this->program->getShortName())); $menu->addLink($link); } $link = new \Foundation\Navigation\Link('Returning Applicants'); $link->setHref($this->path($path . '/applicant/login')); $menu->addLink($link); if (!$this->application->isByInvitationOnly()) { $link = new \Foundation\Navigation\Link('Start a New Application'); $link->addClass('highlight'); $link->setHref($this->path($path . '/applicant/new')); $menu->addLink($link); } } $navigation->addMenu($menu); if ($this->isPreviewMode()) { $menu = new \Foundation\Navigation\Menu(); $navigation->addMenu($menu); $menu->setTitle('Preview Functions'); $link = new \Foundation\Navigation\Link('Become Administrator'); $link->setHref($this->path('admin/login')); $menu->addLink($link); } return $navigation; }
/** * Get the answer counts for each page. * @param Application $application * @return array */ public function getPageAnswerCounts(Application $application) { $query = $this->_em->createQuery('SELECT page.id as pageId, count(answer.id) as answers FROM Jazzee\\Entity\\Answer answer JOIN answer.page page JOIN answer.applicant applicant WHERE answer.applicant IN (SELECT app1.id FROM Jazzee\\Entity\\Applicant app1 WHERE app1.application = :applicationId) GROUP BY answer.applicant, answer.page'); $query->setParameter('applicationId', $application->getId()); $pageAnswers = array(); foreach ($query->getResult() as $arr) { if (!array_key_exists($arr['pageId'], $pageAnswers) or $pageAnswers[$arr['pageId']] < $arr['answers']) { $pageAnswers[$arr['pageId']] = $arr['answers']; } } $pages = array(); foreach ($application->getApplicationPages() as $applicationPage) { if (array_key_exists($applicationPage->getPage()->getId(), $pageAnswers)) { $pages[$applicationPage->getPage()->getId()] = $pageAnswers[$applicationPage->getPage()->getId()]; } else { $pages[$applicationPage->getPage()->getId()] = 0; } } return $pages; }
public function noticeNewComment(Comment $comment, Application $app) { $pkg = null; if ($comment->getPackageId()) { $pkg = PackageDb::retrieveByPK($comment->getPackageId()); } $page_url = mfwRequest::makeURL("/app/comment?id={$app->getId()}#comment-{$comment->getNumber()}"); ob_start(); include APP_ROOT . '/data/notice_comment_mail_template.php'; $body = ob_get_clean(); $addresses = $this->getColumnArray('owner_mail'); if (empty($addresses)) { return; } $subject = "New Comment to {$app->getTitle()}"; $sender = Config::get('mail_sender'); $to = implode(', ', $addresses); $header = "From: {$sender}"; mb_language('uni'); mb_internal_encoding('UTF-8'); return !mb_send_mail($to, $subject, $body, $header); }
/** * All the applicants in an application * @param Application $application * @param \Jazzee\Interfaces\Display $display * @param array $applicantIds * @return array */ public function findPDFTemplateArrayByApplication(Application $application, \Jazzee\Interfaces\Display $display, array $applicantIds) { $results = array(); foreach (array_chunk($applicantIds, 20) as $limitedIds) { $queryBuilder = $this->deepApplicantQuery($display); $queryBuilder->andWhere('applicant.application = :applicationId'); $queryBuilder->andWhere('applicant.deactivated=false'); $queryBuilder->setParameter('applicationId', $application->getId()); $expression = $queryBuilder->expr()->orX(); foreach ($limitedIds as $key => $value) { $paramKey = 'applicantId' . $key; $expression->add($queryBuilder->expr()->eq("applicant.id", ":{$paramKey}")); $queryBuilder->setParameter($paramKey, $value); } $queryBuilder->andWhere($expression); $query = $queryBuilder->getQuery(); $query->setHint(\Doctrine\ORM\Query::HINT_INCLUDE_META_COLUMNS, true); $query->setHydrationMode('ApplicantPDFTemplateHydrator'); $results = array_merge($results, $query->execute()); } return $results; }
foreach ($files as $file) { $file = trim($file); // for cache file, we move it to its proper location if (strpos($file, str_replace(WEBROOT . DS, "", CACHE_DIR)) === 0) { $oldname = WEBROOT . DS . $file; $newname = WEBROOT . DS . "files/application" . str_replace(CACHE_DIR, "", WEBROOT . DS . $file); rename($oldname, $newname); $file = str_replace(WEBROOT . DS, "", $newname); } $rtn[] = $file; } $object->setIeltsTranscripts(implode("\n", $rtn)); $object->setCreatedAt(time()); if ($error_flag == false) { if ($object->save()) { Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Thanks for your application. We will come back to you as soon as possible.", "zh" => "记录保存成功")))); sendemailAdmin('Apply for course', '<p>A new application for course has just been submitted: <br /><a href="http://en.ct21.com.au/admin/application/edit/' . $object->getId() . '">http://en.ct21.com.au/admin/application/edit/' . $object->getId() . '</a></p>'); HTML::forwardBackToReferer(); } else { Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败")))); } } } $html = new HTML(); $html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Create Application', 'zh' => 'Create 申请')))); $html->output('<div id="wrapper">'); $html->renderOut('core/backend/header'); $html->renderOut('application/backend/application_create', array('object' => $object)); $html->output('</div>'); $html->renderOut('core/backend/html_footer'); exit;
} //Delete application if (isset($_GET['delete']) && intval($_GET['delete']) > 0) { $app->deleteApplication(); $msg->addFeedback('GADGET_REMOVED_SUCCESSFULLY'); header('Location: '. $_SERVER['HTTP_REFERER']); exit; } //Display application settings if (isset($_GET['settings'])){ include(AT_INCLUDE_PATH.'header.inc.php'); $savant->assign('settings', $app->getSettings()); //userPrefs $savant->assign('user_settings', $app->getApplicationSettings($_SESSION['member_id'])); $savant->assign('app_id', $app->getId()); //id $savant->display('social/application_settings.tmpl.php'); include(AT_INCLUDE_PATH.'footer.inc.php'); exit; } //Save settings if (isset($_POST['app_settings'])){ foreach ($app->getSettings() as $key=>$value){ if(isset($_POST[$key])){ //save values iff it is in the userPrefs serialized string. //don't save values blindly from the $_POST. $value = $addslashes($_POST[$key]); $app->setApplicationSettings($_SESSION['member_id'], $key, $value); } }
/** * Find all the threads for an application * * @param Application $application * @return Array $threads */ public function findByApplication(Application $application) { $query = $this->_em->createQuery('SELECT t FROM Jazzee\\Entity\\Thread t WHERE t.applicant IN (SELECT a.id from \\Jazzee\\Entity\\Applicant a WHERE a.application = :applicationId) order by t.createdAt DESC'); $query->setParameter('applicationId', $application->getId()); return $query->getResult(); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Application $value A Application object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Application $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
public static function getInstallUsers(Application $app) { $sql = 'SELECT * FROM app_install_user WHERE app_id = ?'; $rows = mfwDBIBase::getAll($sql, array($app->getId())); return new InstallUserSet($app, $rows); }
public static function post(User $user, Application $app, $package_id, $message) { $sql = 'SELECT number FROM comment WHERE app_id=?ORDER BY id DESC LIMIT 1'; $max_num = (int) mfwDBIBase::getOne($sql, array($app->getId())); $row = array('app_id' => $app->getId(), 'package_id' => $package_id ?: null, 'number' => $max_num + 1, 'mail' => $user->getMail(), 'message' => $message, 'created' => date('Y-m-d H:i:s')); $comment = new Comment($row); $comment->insert(); return $comment; }
/** * Get the display for a role * @param Application $application * @return Display */ public function getDisplayForApplication(Application $application) { foreach ($this->displays as $display) { if ($display->getApplication()->getId() == $application->getId()) { return $display; } } return false; }
public static function insertNewApp($owner, $title, $image, $description, $repository) { $now = date('Y-m-d H:i:s'); // insert new application $row = array('title' => $title, 'api_key' => static::makeApiKey(), 'description' => $description, 'repository' => $repository, 'date_to_sort' => $now, 'created' => $now); $app = new Application($row); $app->insert(); // upload icon to S3 $icon_key = static::uploadIcon($image, $app->getId()); $table = static::TABLE_NAME; mfwDBIBase::query("UPDATE {$table} SET icon_key = :icon_key WHERE id= :id", array(':id' => $app->getId(), ':icon_key' => $icon_key)); // insert owner $row = array('app_id' => $app->getId(), 'owner_mail' => $owner->getMail()); $owner = new ApplicationOwner($row); $owner->insert(); return $app; }
/** * find one by application and member * * @param Application $application * @param Member $member * @return MemberApplication */ public function findOneByApplicationAndMember($application, $member) { return $this->createQuery()->where('application_id = ?', $application->getId())->andWhere('member_id =?', $member->getId())->fetchOne(); }
public static function update($values, $user) { $id = $values['id']; if ($id) { $q = new Doctrine_Query(); $q = $q->select('a.*')->from('Application a'); $q = $q->addWhere('id = ?', array($id)); if (!$user->getRole() == User::ADMIN) { $q = $q->addWhere('user_id = ?', array($user->getId())); } $application = $q->fetchOne(); } else { $application = new Application(); } if ($application) { $application->setName($values['name']); $application->setDescription($values['description']); $application->setSourceUrl($values['source_url']); if (!$application->getUserId()) { $application->setUserId($user->getId()); } $application->setApproved(false); $application->save(); $folderpath = $application->getFolderPath(); if (!is_dir($folderpath)) { mkdir($folderpath); } $screenshot = $values['screenshot']; if ($screenshot) { $screenshotpath = $folderpath . $application->getId() . $screenshot->getOriginalName(); $screenshot->save($screenshotpath); $smallThumb = new Thumbnail($screenshotpath); if ($smallThumb->getCurrentWidth() > 150 || $smallThumb->getCurrentHeight() > 150) { $smallThumb->resize(150, 150); } $smallThumb->show(100, $folderpath . 'smallthumb.png'); $bigThumb = new Thumbnail($screenshotpath); if ($bigThumb->getCurrentWidth() > 500 || $bigThumb->getCurrentHeight() > 500) { $bigThumb->resize(500, 500); } $bigThumb->show(100, $folderpath . 'bigthumb.png'); $screenshot = new Thumbnail($screenshotpath); $screenshot->show(100, $folderpath . 'screenshot.png'); unlink($screenshotpath); } return $application; } return null; }
/** * Find all the tags for an application * * @param Application $application * @return array */ public function findByApplication(Application $application) { $query = $this->_em->createQuery('SELECT tag FROM Jazzee\\Entity\\Tag tag INDEX BY tag WHERE tag IN (SELECT t.id FROM Jazzee\\Entity\\Applicant a JOIN a.tags t WHERE a.application = :applicationId) group by tag.id order by tag.title ASC'); $query->setParameter('applicationId', $application->getId()); return $query->getResult(); }
function triggerEvents($cio, $uid) { // instantiate all applications, divide in those who need meta informations and those who don't $applications = array(); $metaapplications = array(); foreach ($this->_GIS->people[$this->_id]->applications as $a) { $application = new Application($a, $this->_id, $this->_log); if ($application) { if ($application->needMeta()) { $metaapplications[] = $application; } else { $applications[] = $application; } } } $this->_log->log(\Psr\Log\LogLevel::DEBUG, "User " . $this->_id . " has " . count($metaapplications) . " applications which need meta informations and " . count($applications) . " which don't need them."); // retrieve metadata for all applications which needs it if (count($metaapplications) > 0) { // we need to be EP manager to retrieve the meta data if (!in_array($uid, $this->_managers)) { $m = $this->_managers; $m[] = $uid; if (!$this->updateEPmanagers($m)) { $this->_log->log(\Psr\Log\LogLevel::WARNING, "Could NOT become EP manager for user " . $this->_id . ". This means we have to skip all applications which need meta data"); $metaapplications = array(); } } // retrieve all the metadata foreach ($metaapplications as $application) { if ($application->setMeta($this->_GIS->applications[$application->getId()]->get()->meta)) { $applications[] = $application; } else { $this->_log->log(\Psr\Log\LogLevel::WARNING, "Could NOT get meta data for application " . $application->getId() . ". Skipping that application."); } } unset($metaapplications); // check if we need to drop EP manager rights if (!in_array($uid, $this->_managers)) { if (!$this->updateEPmanagers($this->_managers)) { $this->_log->log(\Psr\Log\LogLevel::INFO, "Could NOT remove GIS Bot as EP manager from person " . $this->_id, (array) $this->_managers); } } } // trigger the events for every application, but stop if we can not save the state of an application foreach ($applications as $application) { $err = false; while ($application->hasEvent() && !$err) { $application->nextEvent($cio); $err = !$application->saveStatus(); } } }