/** * Creates a PDF report from the Minutes model given. * Returns the PDF as a string that can either be saved to disk * or streamed back to the browser. * * @param Phprojekt_Model_Interface $minutesModel The minutes model object to create the PDF from. * * @return string The resulting PDF document. */ public static function getPdf(Phprojekt_Model_Interface $minutesModel) { $phpr = Phprojekt::getInstance(); $pdf = new Zend_Pdf(); $page = new Phprojekt_Pdf_Page(Zend_Pdf_Page::SIZE_A4); $pages = array($page); $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12); $page->setBorder(2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 3.0 * Phprojekt_Pdf_Page::PT_PER_CM); $page->addFreetext(array('lines' => $minutesModel->title, 'fontSize' => 20)); $page->addFreetext(array('lines' => array_merge(explode("\n\n", $minutesModel->description), array($phpr->translate('Start') . ': ' . $minutesModel->meetingDatetime, $phpr->translate('End') . ': ' . $minutesModel->endTime, $phpr->translate('Place') . ': ' . $minutesModel->place, $phpr->translate('Moderator') . ': ' . $minutesModel->moderator)), 'fontSize' => 12)); $invited = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsInvited); $attending = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsAttending); $excused = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsExcused); $pages += $page->addTable(array('fontSize' => 12, 'rows' => array(array(array('text' => $phpr->translate('Invited'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($invited, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM)), array(array('text' => $phpr->translate('Attending'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($attending, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM)), array(array('text' => $phpr->translate('Excused'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($excused, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM))))); $page = end($pages); $itemtable = array(); $items = $minutesModel->items->fetchAll(); foreach ($items as $item) { $itemtable[] = array(array('text' => $item->topicId, 'width' => 1.3 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate($item->information->getTopicType($item->topicType)), 'width' => 3.0 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $item->getDisplay(), 'width' => 12.4 * Phprojekt_Pdf_Page::PT_PER_CM)); } $pages += $page->addTable(array('fontSize' => 12, 'rows' => array_merge(array(array('isHeader' => true, array('text' => $phpr->translate('No.'), 'width' => 1.3 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate('Type'), 'width' => 3.0 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate('Item'), 'width' => 12.4 * Phprojekt_Pdf_Page::PT_PER_CM))), $itemtable))); $page = end($pages); $pdf->pages = $pages; $pdf->properties['Title'] = $minutesModel->title; $owner = Minutes_Helpers_Userlist::expandIdList($minutesModel->ownerId); $pdf->properties['Author'] = $owner[0]['display']; $pdf->properties['Producer'] = 'PHProjekt version ' . Phprojekt::getVersion(); $pdf->properties['CreationDate'] = 'D:' . gmdate('YmdHis'); $pdf->properties['Keywords'] = $minutesModel->description; return $pdf->render(); }
public function testCompareVersion() { $this->assertGreaterThan(0, Phprojekt::compareVersion("6.0.10", Phprojekt::getVersion())); $this->assertGreaterThan(0, Phprojekt::compareVersion("6.0.1", "6.0.0")); $this->assertLessThan(0, Phprojekt::compareVersion("6.0.1", "6.1.0")); $this->assertGreaterThan(0, Phprojekt::compareVersion("6.0.1-RC2", "6.0.1-RC1")); $this->assertLessThan(0, Phprojekt::compareVersion("6.0.0-RC1", "6.0.0")); $this->assertEquals(0, Phprojekt::compareVersion("6.0.0-RC1", "6.0.0-RC1")); $this->assertEquals(0, Phprojekt::compareVersion("6.0.1", "6.0.1")); }
/** * Index. * * If the user is an admin and we need upgrades, print a form. * Else, print a message depending on the situation. */ public function indexAction() { $config = Phprojekt::getInstance()->getConfig(); $language = Phprojekt_Auth::getRealUser()->getSetting("language", $config->language); $this->view->language = $language; $this->view->compressedDojo = (bool) $config->compressedDojo; $this->view->frontendMsg = (bool) $config->frontendMessages; $this->view->newVersion = Phprojekt::getVersion(); $extensions = new Phprojekt_Extensions(PHPR_CORE_PATH); $migration = new Phprojekt_Migration($extensions); if ($migration->needsUpgrade()) { if (!Phprojekt_Auth::isAdminUser()) { $this->render('upgradeLocked'); } else { $this->view->modules = $migration->getModulesNeedingUpgrade(); $this->render('upgrade'); } } else { $this->render('upgradeIdle'); } }
/** * Delete all the version higher than the current one * and the version lower than the current module version. * * @param string $module Current module of the data. * @param array $data Array with all the version and data for parse. * * @return array Array with only the correct versions. */ private function _getVersionsForProcess($module, $data) { $current = Phprojekt::getVersion(); $moduleVersion = $this->_getModuleVersion($module); foreach (array_keys($data) as $version) { if (Phprojekt::compareVersion($moduleVersion, $version) > 0 || Phprojekt::compareVersion($current, $version) < 0) { unset($data[$version]); } } return $data; }
/** * Returns the front configurations from the configuration.php (front.xxx), * and some others Core Settings. * * The return is an array like ('name' => varName, 'value' => varValue') * * The return is in JSON format. * * @return void */ public function jsonGetConfigurationsAction() { $fronVars = Phprojekt::getInstance()->getConfig()->front; $data = array(); if (null !== $fronVars) { foreach ($fronVars as $key => $value) { $data[] = array('name' => $key, 'value' => $value); } } // System info $data[] = array('name' => 'phprojektVersion', 'value' => Phprojekt::getVersion()); $data[] = array('name' => 'currentUserId', 'value' => Phprojekt_Auth::getUserId()); $data[] = array('name' => 'csrfToken', 'value' => Phprojekt::createCsrfToken()); Phprojekt_Converter_Json::echoConvert($data); }
/** * As defined in Sabre_CalDAV_Backend_Abstract * * Retrieves a single Calendar object. * * @param string $calendarId The id of the calendar. Corresponds to the id of the user it belongs to. * @param string $objectUri The uri of the calendarobject to retrieve. * * @return array As specified by SabreDAV. */ public function getCalendarObject($calendarId, $objectUri) { $db = Phprojekt::getInstance()->getDb(); $events = new Calendar2_Models_Calendar2(); $events = $events->fetchAll($db->quoteInto('uri = ?', $objectUri)); if (!is_array($events) || empty($events)) { return array(); } $calendarData = new Sabre_VObject_Component('vcalendar'); $calendarData->add('version', '2.0'); $calendarData->add('prodid', 'Phprojekt ' . Phprojekt::getVersion()); $lastModified = $events[0]->lastModified; foreach ($events as $e) { $calendarData->add($e->asVObject($events)); $lastModified = max($lastModified, $e->lastModified); } $lastModified = new Datetime($lastModified); return array('id' => $events[0]->uid, 'uri' => $objectUri, 'lastmodified' => $lastModified->format('Ymd\\THis\\Z'), 'calendarid' => $calendarId, 'calendardata' => $calendarData->serialize()); }
/** * Converts a timecard join project join module row to a vobject string. * * @param array $entry * * @return string */ private function _getDataForEntry(array $entry) { $v = new Sabre_VObject_Component('vevent'); if (1 == $entry['project_id']) { $v->add('summary', Phprojekt::getInstance()->translate('Unassigned')); } else { $v->add('summary', $entry['title'] . ' [' . $entry['project_id'] . ']'); } $notes = trim($entry['notes']); if (!is_null($entry['module_id'])) { if ($notes) { $notes .= "\n"; } $notes .= Phprojekt::getInstance()->translate('There is an attachment of type ') . Phprojekt::getInstance()->translate($entry['label']); } if ($notes) { $v->add('description', $notes); } $start = new DateTime('@' . Phprojekt_Converter_Time::userToUtc($entry['start_datetime'])); $end = substr($entry['start_datetime'], 0, 11) . $entry['end_time']; $end = new DateTime('@' . Phprojekt_Converter_Time::userToUtc($end)); $v->add('dtstart', $start->format('Ymd\\THis\\Z')); $v->add('dtend', $end->format('Ymd\\THis\\Z')); $v->add('uid', 'phprojekt-timecard-entry' . $entry['uid']); $calendarData = new Sabre_VObject_Component('vcalendar'); $calendarData->add('version', '2.0'); $calendarData->add('prodid', 'Phprojekt ' . Phprojekt::getVersion()); $calendarData->add($v); return $calendarData->serialize(); }
/** * Returns the front configurations from the configuration.php (front.xxx), * and some others Core Settings. * * The return is an array like ('name' => varName, 'value' => varValue') * * The return is in JSON format. * * @return void */ public function jsonGetConfigurationsAction() { $fronVars = Phprojekt::getInstance()->getConfig()->front; $data = array(); if (null !== $fronVars) { foreach ($fronVars as $key => $value) { $data[] = array('name' => $key, 'value' => $value); } } $user = Phprojekt_Auth_Proxy::getEffectiveUser(); $settings = $user->settings->fetchAll(); $tutorialDisplayed = "false"; foreach ($settings as $setting) { if ($setting->keyValue == "tutorialDisplayed") { $tutorialDisplayed = $setting->value; break; } } // System info $data[] = array('name' => 'phprojektVersion', 'value' => Phprojekt::getVersion()); $data[] = array('name' => 'currentUserId', 'value' => $user->id); $data[] = array('name' => 'currentUserName', 'value' => $user->username); $data[] = array('name' => 'csrfToken', 'value' => Phprojekt::createCsrfToken()); $data[] = array('name' => 'tutorialDisplayed', 'value' => $tutorialDisplayed); Phprojekt_Converter_Json::echoConvert($data); }