Пример #1
0
 /**
  * @param Phprojekt $phprojekt
  * @param $username
  * @param $password
  */
 protected function doLogin($phprojekt)
 {
     //		$this->comment('[Action] Try to login');
     try {
         $success = $phprojekt->login();
         if (!$success) {
             exit($this->comment('[Response] Login Failed!'));
         }
         //			$this->comment('[Response] Login successful');
     } catch (InvalidArgumentException $e) {
     }
 }
Пример #2
0
 /**
  * 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();
 }
Пример #3
0
 public function indexAction()
 {
     // Set the root directory
     $webdavPath = Phprojekt::getInstance()->getConfig()->webdavPath;
     if (Phprojekt_Auth::isLoggedIn()) {
         $project = new Project_Models_Project();
         $project = $project->find(1);
         $rootDirectory = new WebDAV_Models_ProjectDirectory($project);
     } else {
         // Some clients seem to send some queries without http auth. We need the dummy to serve those.
         $rootDirectory = new WebDAV_Models_EmptyDir();
     }
     // The server object is responsible for making sense out of the WebDAV protocol
     $server = new Sabre_DAV_Server($rootDirectory);
     $server->setBaseUri($this->view->baseUrl('index.php/WebDAV/index/index/'));
     // The lock manager is reponsible for making sure users don't overwrite each others changes.
     // Change 'data' to a different directory, if you're storing your data somewhere else.
     $lockBackend = new Sabre_DAV_Locks_Backend_File($webdavPath . 'data/locks');
     $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
     $server->addPlugin($lockPlugin);
     // Authentication
     $authBackend = new WebDAV_Helper_Auth();
     $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'WebDAV');
     $server->addPlugin($authPlugin);
     // All we need to do now, is to fire up the server
     $server->exec();
 }
Пример #4
0
 /**
  * Default error action.
  *
  * On Zend_Controller_Action_Exception, if the error code is 4xx return an error message matching the accepted type.
  *
  * On wrong controller name or action, terminates script execution.
  *
  * In all cases, the error is logged.
  *
  * @return void
  */
 public function errorAction()
 {
     $error = $this->_getParam('error_handler');
     $this->getResponse()->clearBody();
     $exception = $error->exception;
     $viewerror = array('type' => 'error', 'message' => 'Internal Server Error');
     switch ($error->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             // 404 error -- controller or action not found
             $this->getResponse()->setHttpResponseCode(404);
             $message = "The url " . Cleaner::sanitize('xss', urldecode($error->request->getRequestUri())) . " do not exists";
             Phprojekt::getInstance()->getLog()->err($message);
             die($message);
             break;
         default:
             // We only forward exception with 4xx code to the client
             if ($exception instanceof Zend_Controller_Action_Exception && $exception->getCode() >= 400 && $exception->getCode() < 500) {
                 $this->getResponse()->setHttpResponseCode($exception->getCode());
                 $viewerror['message'] = $exception->getMessage();
             } else {
                 $this->getResponse()->setHttpResponseCode(500);
                 $logger = Phprojekt::getInstance()->getLog();
                 $logger->err($exception->getMessage() . "\n" . $exception->getTraceAsString());
             }
             break;
     }
     $this->view->error = $viewerror;
 }
Пример #5
0
 /**
  * Constructor
  *
  * @param string $name The name of the file to represent
  * @param string $hash The md5 hash of the file to represent
  * @param Filemanager_Models_Filemanager
  *               $filemanager The filemanager object that the file is a part of.
  */
 public function __construct($name, $hash, $filemanager)
 {
     $this->_name = $name;
     $this->_hash = $hash;
     $this->_filemanager = $filemanager;
     parent::__construct(Phprojekt::getInstance()->getConfig()->uploadPath . '/' . $hash);
 }
Пример #6
0
 /**
  * Return the display data for a moduleId-ItemId pair.
  *
  * @param array $data Array with the module data for show (moduleId => itemId).
  *
  * @return array Array with 'id', 'moduleId', 'moduleName', 'moduleLabel',
  *                          'firstDisplay', 'secondDisplay' and 'projectId'.
  */
 public function getDisplay($data)
 {
     $results = array();
     foreach ($data as $moduleId => $content) {
         $ids = array();
         foreach ($content as $id) {
             $ids[] = (int) $id;
         }
         if (!empty($ids)) {
             $where = sprintf('module_id = %d AND item_id IN (%s)', (int) $moduleId, implode(', ', $ids));
             $tmpResult = $this->fetchAll($where)->toArray();
             $moduleName = Phprojekt_Module::getModuleName($moduleId);
             $moduleLabel = Phprojekt::getInstance()->translate(Phprojekt_Module::getModuleLabel($moduleId), null, $moduleName);
             foreach ($tmpResult as $result) {
                 $index = $moduleId . '-' . $result['item_id'];
                 $results[$index] = array('id' => (int) $result['item_id'], 'moduleId' => (int) $moduleId, 'moduleName' => $moduleName, 'moduleLabel' => $moduleLabel, 'firstDisplay' => $result['first_display'], 'secondDisplay' => $result['second_display'], 'projectId' => (int) $result['project_id']);
             }
             foreach ($ids as $id) {
                 $index = $moduleId . '-' . $id;
                 if (!isset($results[$index])) {
                     $results[$index] = array('id' => (int) $id, 'moduleId' => (int) $moduleId, 'moduleName' => Phprojekt_Module::getModuleName($moduleId), 'moduleLabel' => $moduleLabel, 'firstDisplay' => '', 'secondDisplay' => '', 'projectId' => 1);
                 }
             }
         }
     }
     return array_values($results);
 }
Пример #7
0
 /**
  * Test the getModel functionality
  */
 public function testGetModel()
 {
     $name = new Project_Models_Project();
     $this->assertEquals('Project_Models_Project', get_class($name));
     $instance = new $name(array('db' => Phprojekt::getInstance()->getDb()));
     $this->assertTrue($instance instanceof Project_Models_Project);
 }
Пример #8
0
 /**
  * Constructor
  */
 public function __construct($db = null)
 {
     if (is_null($db)) {
         $db = Phprojekt::getInstance()->getDb();
     }
     $this->_proxyTable = new Zend_Db_Table(array('db' => $db, 'name' => 'user_proxy'));
 }
Пример #9
0
 /**
  * setup the unit test. Use firefox as a browser and the document
  * root from the configuration file
  *
  * @return void
  */
 function setUp()
 {
     $this->setAutoStop(false);
     $this->config = Phprojekt::getInstance()->getConfig();
     $this->verificationErrors = array();
     $this->setBrowserUrl($this->config->webpath);
 }
Пример #10
0
 /**
  * Default error action.
  *
  * On Phprojekt_PublishedException, return an error string in JSON format.
  * <pre>
  *  - type    => 'error'.
  *  - message => Error message.
  *  - code    => Error code.
  * </pre>
  *
  * On wrong controller name or action, terminates script execution.
  *
  * In all cases, the error is logged.
  *
  * @return void
  */
 public function errorAction()
 {
     $error = $this->_getParam('error_handler');
     $this->getResponse()->clearBody();
     switch ($error->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             // 404 error -- controller or action not found
             $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
             $message = "The url " . Cleaner::sanitize('xss', urldecode($error->request->getRequestUri())) . " do not exists";
             Phprojekt::getInstance()->getLog()->err($message);
             die($message);
             break;
         default:
             $exception = $error->exception;
             // We only forward exception with type PublishedException
             if ($exception instanceof Phprojekt_PublishedException) {
                 $error = array('type' => 'error', 'message' => $exception->getMessage(), 'code' => $exception->getCode());
                 echo '{}&&(' . Zend_Json_Encoder::encode($error) . ')';
             } else {
                 $logger = Phprojekt::getInstance()->getLog();
                 $logger->err($exception->getMessage() . "\n" . $exception->getTraceAsString());
             }
             break;
     }
 }
Пример #11
0
 /**
  * Normal cal
  */
 public function testLog()
 {
     $config = Phprojekt::getInstance()->getConfig();
     $log = new Phprojekt_Log($config);
     $log->log('TEST', Zend_Log::DEBUG);
     $log->log('TEST', Zend_Log::CRIT);
     $log->log('TEST', Zend_Log::INFO);
 }
Пример #12
0
 /**
  * Construct a new instance with the given path.
  *
  * The path defines where to search for extensions.
  *
  * @param string $path The directory to search for extensions.
  */
 public function __construct($path)
 {
     $this->_log = Phprojekt::getInstance()->getLog();
     $this->_config = Phprojekt::getInstance()->getConfig();
     $this->_cache = Phprojekt::getInstance()->getCache();
     $this->_path = $path;
     $this->_cacheNs = self::CACHE_NS . md5($this->_path);
 }
Пример #13
0
 public function testMigrationMakesFilenamesUnique()
 {
     $migration = new Filemanager_Migration();
     $migration->upgrade('6.1.0', Phprojekt::getInstance()->getDb());
     $rows = Phprojekt::getInstance()->getDb()->select()->from('filemanager', array('id', 'files'))->order('id')->query()->fetchAll();
     $expected = array(array('id' => '1', 'files' => '966f9bfa01ec4a2a3fa6282bb8fa8d56|articles.txt (1)||aaaaaa|articles.txt (2)'), array('id' => '2', 'files' => 'deadbeef01ec4a2a3fa6282bb8fa8d56|articles.txt|articles.txt2'), array('id' => '3', 'files' => '2b00042f7481c7b056c4b410d28f33cf|foo (1)||' . '2219d815ba0757484194cac396115c6a|foo (2)||' . 'd8016131a2724252b2419bf645aab221|bar'));
     $this->assertEquals($expected, $rows);
 }
Пример #14
0
 /**
  * Test getModules
  */
 public function testGetModules()
 {
     $setting = new Phprojekt_Setting();
     $data = array();
     $data[] = array('name' => 'User', 'label' => Phprojekt::getInstance()->translate('User'));
     $data[] = array('name' => 'Notification', 'label' => Phprojekt::getInstance()->translate('Notification'));
     $data[] = array('name' => 'Timecard', 'label' => Phprojekt::getInstance()->translate('Timecard'));
     $this->assertEquals($data, $setting->getModules());
 }
Пример #15
0
 /**
  * setUp method for PHPUnit. We use a shared db connection
  */
 public function setUp()
 {
     parent::setUp();
     $this->_emptyResult = array();
     $this->_formResult = array('projectId' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''), 'title' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''), 'notes' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''), 'startDate' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''), 'endDate' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''), 'priority' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''), 'currentStatus' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''), 'completePercent' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''), 'budget' => array('id' => '', 'tableName' => '', 'tablefield' => '', 'formTab' => '', 'formLabel' => '', 'formType' => '', 'formPosition' => '', 'formColumns' => '', 'formRegexp' => '', 'formRange' => '', 'defaultValue' => '', 'listPosition' => '', 'listAlign' => '', 'listUseFilter' => '', 'altPosition' => '', 'status' => '', 'isInteger' => '', 'isRequired' => '', 'isUnique' => ''));
     $this->_listResult = array('title' => $this->_formResult['title'], 'startDate' => $this->_formResult['startDate'], 'endDate' => $this->_formResult['endDate'], 'priority' => $this->_formResult['priority'], 'currentStatus' => $this->_formResult['currentStatus'], 'completePercent' => $this->_formResult['completePercent']);
     $this->_filterResult = array('title' => $this->_formResult['title'], 'start_date' => $this->_formResult['startDate'], 'end_date' => $this->_formResult['endDate'], 'priority' => $this->_formResult['priority'], 'current_status' => $this->_formResult['currentStatus'], 'complete_percent' => $this->_formResult['completePercent']);
     $this->sharedFixture = Phprojekt::getInstance()->getDb();
 }
Пример #16
0
 /**
  * Initialize new tab.
  *
  * @param array $db Configuration for Zend_Db_Table.
  *
  * @return void
  */
 public function __construct($db = null)
 {
     if (null === $db) {
         $db = Phprojekt::getInstance()->getDb();
     }
     parent::__construct($db);
     $this->_validate = new Phprojekt_Model_Validate();
     $this->_informationManager = new Phprojekt_Tab_Information();
 }
Пример #17
0
 /**
  * Initialize new tab.
  *
  * @param array $db Configuration for Zend_Db_Table.
  *
  * @return void
  */
 public function __construct($db = null)
 {
     if (null === $db) {
         $db = Phprojekt::getInstance()->getDb();
     }
     parent::__construct($db);
     $this->_validate = Phprojekt_Loader::getLibraryClass('Phprojekt_Model_Validate');
     $this->_informationManager = Phprojekt_Loader::getLibraryClass('Phprojekt_Tab_Information');
 }
Пример #18
0
 public function getAction()
 {
     $id = (int) $this->_getParam('id');
     $record = $this->newModelObject();
     if (!empty($id)) {
         $record = $record->find($id);
         Phprojekt::setCurrentProjectId($record->projectId);
     }
     Phprojekt_CompressedSender::send(Zend_Json_Encoder::encode(Phprojekt_Model_Converter::convertModel($record)));
 }
Пример #19
0
 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"));
 }
Пример #20
0
 /**
  * setUp method for PHPUnit. We use a shared db connection
  */
 public function setUp()
 {
     parent::setUp();
     $this->_emptyResult = array();
     $this->_formResult = array('title', 'notes', 'projectId', 'startDate', 'endDate', 'priority', 'currentStatus', 'completePercent', 'budget', 'contactId');
     $this->_formLabelResult = array('Title', 'Notes', 'Parent', 'Start date', 'End date', 'Priority', 'Current status', 'Complete percent', 'Budget', 'Contact');
     $this->_listResult = array('title', 'startDate', 'endDate', 'priority', 'currentStatus', 'completePercent');
     $this->_listLabelResult = array('Title', 'Start date', 'End date', 'Priority', 'Current status', 'Complete percent');
     $this->sharedFixture = Phprojekt::getInstance()->getDb();
 }
Пример #21
0
 /**
  * Validate the configurations.
  *
  * @param array $params Array with values to save.
  *
  * @return string|null Error message.
  */
 public function validateConfigurations($params)
 {
     $message = null;
     // Company Name
     $companyName = Cleaner::sanitize('string', $params['companyName']);
     if (empty($companyName)) {
         $message = Phprojekt::getInstance()->translate('The Company name is empty');
     }
     return $message;
 }
Пример #22
0
 /**
  * Upgrade to the latest version.
  *
  * @param String $currentVersion Phprojekt version string indicating our
  *                               current version
  * @param Zend_Db_Adapter_Abstract $db The database to use
  *
  * @return void
  * @throws Exception On Errors
  */
 public function upgrade($currentVersion, Zend_Db_Adapter_Abstract $db)
 {
     $this->_db = $db;
     if (Phprojekt::compareVersion($currentVersion, '6.1.5') < 0) {
         $this->_renameFilemanagersWithSameTitle();
         $this->parseDbFile('Filemanager');
         Phprojekt::getInstance()->getCache()->clean(Zend_Cache::CLEANING_MODE_ALL);
         $this->_renameFilesWithSameName();
     }
 }
Пример #23
0
 /**
  * Constructor.
  *
  * @return void
  */
 public function __construct()
 {
     $config = array('db' => Phprojekt::getInstance()->getDb());
     $file = Phprojekt::getInstance()->getConfig()->searchStopwordList;
     if (file_exists($file)) {
         $tmp = file_get_contents($file);
         $this->_stopWords = $this->_stringToArray($tmp);
     }
     parent::__construct($config);
 }
Пример #24
0
 /**
  * Do some checks before install.
  *
  * @throws Expeption If the server don't have the requirements.
  *
  * @return void
  */
 private function _checkServer()
 {
     // Check the server
     $checkServer = Phprojekt::checkExtensionsAndSettings();
     // Check the PHP version
     if (!$checkServer['requirements']['php']['checked']) {
         $missingRequirements[] = "You need the PHP Version " . $checkServer['requirements']['php']['required'] . " or newer. Follow this link for help: <a href=\"" . $checkServer['requirements']['php']['help'] . "\"" . " target=\"_new\">HELP</a>";
     }
     // Check required extension
     foreach ($checkServer['requirements']['extension'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "The '" . $name . "' extension must be enabled. Follow this link for help: " . "<a href=\"" . $values['help'] . "\" target=\"_new\">HELP</a>";
         }
     }
     // Check required settings
     foreach ($checkServer['requirements']['settings'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "The php.ini setting of '" . $name . "' has to be '" . $values['required'] . "'. Follow this link for help: <a href=\"" . $values['help'] . "\"" . " target=\"_new\">HELP</a>";
         }
     }
     // Checking if configuration.php exists
     $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']);
     if (file_exists($baseDir . "configuration.php")) {
         throw new Exception("Configuration file found. Please, delete it before run setup again.");
     }
     if (!empty($missingRequirements)) {
         $message = implode("\n", $missingRequirements);
         throw new Exception($message);
     }
     if (strncmp($_SERVER['SCRIPT_NAME'], '/setup.php', 10) != 0) {
         $this->_message[] = "It is recommend install PHProjekt 6 using a virtual host.<br />" . "You should try to generate an extra virtual host (or a sub-domain) to phprojekt/htdocs.";
         // Works the .htaccess?
         $response = new Zend_Controller_Request_Http();
         $webpath = $response->getHttpHost();
         $str = '';
         $sock = fsockopen($webpath, $response->getServer('SERVER_PORT'));
         $request = "GET " . str_replace('htdocs/setup.php', '', $response->getRequestUri()) . '/application/' . " HTTP/1.1\r\n" . "Host: " . $webpath . "\r\nConnection: close\r\n\r\n";
         fwrite($sock, $request);
         while ($buff = fread($sock, 1024)) {
             $str .= $buff;
         }
         $response = Zend_Http_Response::fromString($str);
         if ($response->getStatus() != '403') {
             $this->_message[] = "Please note that your webserver needs to support .htaccess files " . "to deny access to the configuration files.<br />" . "Running PHProjekt 6 without using the provided .htaccess files to deny access to " . "certain files and folders, might not be secure and is not recommended.";
         }
         fclose($sock);
     }
     foreach ($checkServer['recommendations']['settings'] as $name => $values) {
         if (!$values['checked']) {
             $this->_message[] = "It is recommend to have '" . $name . "' set to '" . $values['required'] . "', but it is not required to run PHProjekt. Follow this link for help: <a href=\"" . $values['help'] . "\" target=\"_new\">HELP</a>";
         }
     }
 }
Пример #25
0
 public function testDelete()
 {
     $filemanager = new Filemanager_Models_Filemanager();
     $filemanager = $filemanager->find(1);
     $filename = Phprojekt::getInstance()->getConfig()->uploadPath . '/966f9bfa01ec4a2a3fa6282bb8fa8d56';
     file_put_contents($filename, 'content');
     $file = new WebDAV_Models_FilemanagerFile('articles.txt', '966f9bfa01ec4a2a3fa6282bb8fa8d56', $filemanager);
     $file->delete();
     $filemanager = new Filemanager_Models_Filemanager();
     $filemanager = $filemanager->find(1);
     $this->assertEquals('', $filemanager->files);
     $this->assertFileNotExists($filename);
 }
Пример #26
0
 /**
  * Upgrade to the latest version.
  *
  * @param String $currentVersion Phprojekt version string indicating our
  *                               current version
  * @param Zend_Db_Adapter_Abstract $db The database to use
  *
  * @return void
  * @throws Exception On Errors
  */
 public function upgrade($currentVersion, Zend_Db_Adapter_Abstract $db)
 {
     date_default_timezone_set('utc');
     $this->_db = $db;
     $this->parseDbFile('Timecard');
     if (Phprojekt::compareVersion($currentVersion, '6.1.4') < 0) {
         $request = new Zend_Controller_Request_Http();
         $uidSuffix = "@phprojekt6-" . $request->getHttpHost();
         Phprojekt::getInstance()->getDB()->query("UPDATE timecard SET uri = id, uid = CONCAT(UUID(), \"{$uidSuffix}\");");
         // This is mysql-only. Not sure if this is the ultimate way to go here.
         Phprojekt::getInstance()->getDB()->query('ALTER TABLE timecard ADD UNIQUE (uri)');
     }
 }
Пример #27
0
 /**
  * Returns the string used for end of line in text mode emails, according to config file setting.
  *
  * @return string End of line characters.
  */
 protected function getEndOfLine()
 {
     switch (Phprojekt::getInstance()->getConfig()->mailEndOfLine) {
         case self::LINEEND_N:
             $endOfLine = "\n";
             break;
         case self::LINEEND_RN:
         default:
             $endOfLine = "\r\n";
             break;
     }
     return $endOfLine;
 }
Пример #28
0
 /**
  * Returns the fields part of the Notification body.
  *
  * @param Zend_Locale $lang Locale for use in translations.
  *
  * @return array Array with 'field', 'label' and 'value'.
  */
 public function getBodyFields($lang)
 {
     $fields = parent::getBodyFields($lang);
     foreach ($fields as $k => $f) {
         if ($f['field'] == 'occurrence' || $f['field'] == 'rrule' || $f['field'] == 'confirmationStatuses') {
             unset($fields[$k]);
         }
         if ($f['field'] == 'participants') {
             $fields[$k]['value'] = $this->_model->getParticipantsNames();
         }
     }
     $fields[] = array('field' => 'recurrence', 'label' => Phprojekt::getInstance()->translate('Recurrence'), 'value' => $this->_model->recurrence);
     return $fields;
 }
Пример #29
0
 /**
  * Returns the statistics data.
  *
  * The return have
  * <pre>
  *  - users    => id and display of all the users involved
  *  - projects => id and display of all the projects involved.
  *  - rows     => pair projectId => userId - Booked minutes.
  * </pre>
  *
  * OPTIONAL request parameters:
  * <pre>
  *  - date    <b>startDate</b> ISO start date for filter.
  *  - date    <b>endDate</b>   ISO end date for filter.
  *  - integer <b>nodeId</b>    List all the projects under nodeId.
  * </pre>
  *
  * The return is in JSON format.
  *
  * @throws Zend_Controller_Action_Exception On error in the parameters.
  *
  * @return void
  */
 public function jsonGetStatisticAction()
 {
     $startDate = Cleaner::sanitize('date', $this->getRequest()->getParam('startDate', date("Y-m-d")));
     $endDate = Cleaner::sanitize('date', $this->getRequest()->getParam('endDate', date("Y-m-d")));
     $projectId = (int) $this->getRequest()->getParam('nodeId', null);
     if ($startDate <= $endDate) {
         $data = $this->getModelObject()->getStatistics($startDate, $endDate, $projectId);
         Phprojekt_Converter_Json::echoConvert($data);
     } else {
         $messageTitle = Phprojekt::getInstance()->translate('Period');
         $messageDesc = Phprojekt::getInstance()->translate('End time can not be before Start time');
         throw new Zend_Controller_Action_Exception($messageTitle . ': ' . $messageDesc, 400);
     }
 }
Пример #30
0
 /**
  * Validate function for the projectId field.
  *
  * @param integer $value Value of the projectId to check.
  *
  * @return string Error msg.
  */
 public function validateProjectId($value)
 {
     if (null !== $this->id && $this->id > 0) {
         $node = Phprojekt_Loader::getModel('Project', 'Project')->find($this->id);
         $tree = new Phprojekt_Tree_Node_Database($node, $this->id);
         if ($tree->setup()->getActiveRecord()->id == $value) {
             return Phprojekt::getInstance()->translate('The project can not be saved under itself');
         } else {
             if ($this->_isInTheProject($value, $tree)) {
                 return Phprojekt::getInstance()->translate('The project can not be saved under its children');
             }
         }
     }
     return null;
 }