/**
  * Returns the data to show in the index action
  *
  * Allows to easily add or modifiy the information at project level
  *
  * @return array
  */
 protected function _getData()
 {
     $versions = $this->loader->getVersions();
     $data[$this->_('Project name')] = $this->project->getName();
     $data[$this->_('Project version')] = $versions->getProjectVersion();
     $data[$this->_('Gems version')] = $versions->getGemsVersion();
     $data[$this->_('Gems build')] = $versions->getBuild();
     $data[$this->_('Gems project')] = GEMS_PROJECT_NAME;
     $data[$this->_('Gems web directory')] = $this->getDirInfo(GEMS_WEB_DIR);
     $data[$this->_('Gems root directory')] = $this->getDirInfo(GEMS_ROOT_DIR);
     $data[$this->_('Gems code directory')] = $this->getDirInfo(GEMS_LIBRARY_DIR);
     $data[$this->_('Gems variable directory')] = $this->getDirInfo(GEMS_ROOT_DIR . '/var');
     $data[$this->_('MUtil version')] = \MUtil_Version::get();
     $data[$this->_('Zend version')] = \Zend_Version::VERSION;
     $data[$this->_('Application environment')] = APPLICATION_ENV;
     $data[$this->_('Application baseuri')] = $this->loader->getUtil()->getCurrentURI();
     $data[$this->_('Application directory')] = $this->getDirInfo(APPLICATION_PATH);
     $data[$this->_('Application encoding')] = APPLICATION_ENCODING;
     $data[$this->_('PHP version')] = phpversion();
     $data[$this->_('Server Hostname')] = php_uname('n');
     $data[$this->_('Server OS')] = php_uname('s');
     $data[$this->_('Time on server')] = date('r');
     $driveVars = array($this->_('Session directory') => \Zend_Session::getOptions('save_path'), $this->_('Temporary files directory') => realpath(getenv('TMP')));
     if ($system = getenv('SystemDrive')) {
         $driveVars[$this->_('System Drive')] = realpath($system);
     }
     foreach ($driveVars as $name => $drive) {
         $data[$name] = $this->getDirInfo($drive);
     }
     return $data;
 }
 /**
  * Should handle execution of the task, taking as much (optional) parameters as needed
  *
  * The parameters should be optional and failing to provide them should be handled by
  * the task
  */
 public function execute($trackId = null, $exportOrganizations = false)
 {
     $versions = $this->loader->getVersions();
     $data = array('gems_version' => $versions->getGemsVersion(), 'project' => $this->project->getName(), 'project_env' => APPLICATION_ENV, 'project_url' => $this->util->getCurrentURI(), 'project_version' => $versions->getProjectVersion());
     // Main version data
     $this->exportTypeHeader('version', false);
     $this->exportFieldHeaders($data);
     $this->exportFieldData($data);
     $this->exportFlush();
 }
 /**
  * Set those settings needed for the browse display
  *
  *
  * @return \Gems_Model_OrganizationModel
  */
 public function applyBrowseSettings()
 {
     $dbLookup = $this->util->getDbLookup();
     $definitions = $this->loader->getUserLoader()->getAvailableStaffDefinitions();
     $localized = $this->util->getLocalized();
     $projectName = $this->project->getName();
     $yesNo = $this->util->getTranslated()->getYesNo();
     $this->resetOrder();
     $this->set('gor_name', 'label', $this->_('Name'), 'tab', $this->_('General'));
     $this->set('gor_location', 'label', $this->_('Location'));
     $this->set('gor_task', 'label', $this->_('Task'), 'description', sprintf($this->_('Task in %s project'), $projectName));
     $this->set('gor_url', 'label', $this->_('Url'));
     $this->setIfExists('gor_url_base', 'label', $this->_("Default url's"), 'description', sprintf($this->_("Always switch to this organization when %s is accessed from one of these space separated url's. The first is used for mails."), $projectName));
     $this->setIfExists('gor_code', 'label', $this->_('Organization code'), 'description', $this->_('Optional code name to link the organization to program code.'));
     $this->set('gor_provider_id', 'label', $this->_('Healtcare provider id'), 'description', $this->_('An interorganizational id used for import and export.'));
     $this->setIfExists('gor_active', 'label', $this->_('Active'), 'description', $this->_('Can the organization be used?'), 'multiOptions', $yesNo);
     $this->set('gor_contact_name', 'label', $this->_('Contact name'));
     $this->set('gor_contact_email', 'label', $this->_('Contact email'));
     // Determine order for details, but do not show in browse
     $this->set('gor_welcome');
     $this->set('gor_signature');
     $this->set('gor_create_account_template');
     $this->set('gor_reset_pass_template');
     $this->set('gor_has_login', 'label', $this->_('Login'), 'description', $this->_('Can people login for this organization?'), 'multiOptions', $yesNo);
     $this->set('gor_add_respondents', 'label', $this->_('Accepting'), 'description', $this->_('Can new respondents be added to the organization?'), 'multiOptions', $yesNo);
     $this->set('gor_has_respondents', 'label', $this->_('Respondents'), 'description', $this->_('Does the organization have respondents?'), 'multiOptions', $yesNo);
     $this->set('gor_respondent_group', 'label', $this->_('Respondent group'), 'description', $this->_('Allows respondents to login.'), 'multiOptions', $dbLookup->getAllowedRespondentGroups());
     $this->set('gor_accessible_by', 'label', $this->_('Accessible by'), 'description', $this->_('Checked organizations see this organizations respondents.'), 'multiOptions', $dbLookup->getOrganizations());
     $tp = new \MUtil_Model_Type_ConcatenatedRow(':', ', ');
     $tp->apply($this, 'gor_accessible_by');
     $this->setIfExists('gor_allowed_ip_ranges');
     if ($definitions && count($definitions) > 1) {
         $this->setIfExists('gor_user_class', 'label', $this->_('User Definition'), 'multiOptions', $definitions);
     }
     $this->setIfExists('gor_resp_change_event', 'label', $this->_('Respondent change event'), 'multiOptions', $this->loader->getEvents()->listRespondentChangedEvents());
     $this->setIfExists('gor_iso_lang', 'label', $this->_('Language'), 'multiOptions', $localized->getLanguages());
     if ($this->_styles) {
         $this->setIfExists('gor_style', 'label', $this->_('Style'), 'multiOptions', $this->_styles);
     }
     return $this;
 }
예제 #4
0
 /**
  * Add the token to every page of a pdf
  *
  * @param \Zend_Pdf $pdf
  * @param string $tokenId
  * @param int $surveyId
  */
 protected function addTokenToDocument(\Zend_Pdf $pdf, $tokenId, $surveyId)
 {
     $token = strtoupper($tokenId);
     foreach (array('Title', 'Subject', 'Keywords') as $name) {
         if (isset($pdf->properties[$name])) {
             $value = rtrim($pdf->properties[$name]) . ' ' . $token;
         } else {
             $value = $token;
         }
         $pdf->properties[$name] = $value;
     }
     // Acrobat defined date format D:YYYYMMDDHHmmSSOHH'mm
     $pdf->properties['ModDate'] = 'D:' . str_replace(':', "'", date('YmdHisP')) . "'";
     $pdf->properties['Producer'] = $this->project->getName();
     // Avoid warning on Word with a (R) symbol
     $pdf->properties['Creator'] = $this->project->getName();
     // Avoid warning on Word with a (R) symbol
 }
예제 #5
0
 /**
  * Start the cron mail monitor
  *
  * @return boolean True when the job was started
  */
 public function reverseMaintenanceMonitor()
 {
     $job = new MonitorJob($this->project->getName() . ' maintenance mode');
     $lock = $this->util->getMaintenanceLock();
     if ($lock->isLocked()) {
         $job->stop();
         $lock->unlock();
         return false;
     }
     $lock->lock();
     $roles = $this->util->getDbLookup()->getRolesByPrivilege('pr.maintenance.maintenance-mode');
     if ($roles) {
         $where = 'gsf_id_primary_group IN (SELECT ggp_id_group FROM gems__groups WHERE ggp_role IN (' . implode(', ', array_map(array($this->db, 'quote'), array_keys($roles))) . '))';
     } else {
         $where = null;
     }
     $to = $this->_getMailTo('maintenancemode', $where);
     if (!$to) {
         return true;
     }
     switch ($this->project->getLocaleDefault()) {
         case 'nl':
             $initSubject = "{name} is aangezet";
             $initBbText = "L.S.,\n\nDe [b]{name}[/b] is op {setTime} aangezet.\n\nZolang dit aan blijft staan kan u regelmatig waarschuwingen krijgen.\n\nDit is een automatisch bericht.";
             $subject = "{name} staat al meer dan {periodHours} uur aan";
             $messageBbText = "L.S.,\n\nDe [b]{name}[/b] is op {setTime} aangezet en staat nog steeds aan.\n\nDit is waarschuwing nummer [b]{mailCount}[/b]. Controleer s.v.p. of de onderhouds modus nog steeds nodig is.\n\nDit is een automatische waarschuwing.";
             break;
         default:
             $initSubject = "{name} has been turned on";
             $initBbText = "L.S.,\n\nThe [b]{name}[/b] was activated at {setTime}.\n\nAs long as maintenance mode is active the system may send you warning messages.\n\nThis messages was send automatically.";
             $subject = "{name} has been active for over {periodHours} hours";
             $messageBbText = "L.S.,\n\nThe [b]{name}[/b] was activated at {setTime} and is still active.\n\nThis is notice number {mailCount}. Please check whether the maintenance mode is still required.\n\nThis messages was send automatically.";
             break;
     }
     $job->setFrom($this->project->getMonitorFrom('maintenancemode'))->setMessage($messageBbText)->setPeriod($this->project->getMonitorPeriod('maintenancemode'))->setSubject($subject)->setTo($to);
     if ($job->start()) {
         $job->sendOtherMail($initSubject, $initBbText);
     }
     return true;
 }
 /**
  * A specific report on the escort class
  */
 protected function addEscortReport()
 {
     $this->html->h2('Project and escort class report');
     $escortClass = get_class($this->escort);
     $foundNone = true;
     $projectName = $this->project->getName();
     $oldInterfaces = array('Gems_Project_Log_LogRespondentAccessInterface', 'Gems_Project_Organization_MultiOrganizationInterface', 'Gems_Project_Organization_SingleOrganizationInterface', 'Gems_Project_Tracks_FixedTracksInterface', 'Gems_Project_Tracks_StandAloneSurveysInterface', 'Gems_Project_Tracks_TracksOnlyInterface');
     foreach ($oldInterfaces as $interface) {
         if ($this->escort instanceof $interface) {
             $foundNone = false;
             $this->html->pInfo(sprintf('%s implements the deprecated %s interface. Remove this interface.', $escortClass, $interface));
         }
     }
     $snippetsDir = APPLICATION_PATH . '\\snippets';
     if (file_exists($snippetsDir)) {
         $foundNone = false;
         $this->html->pInfo(sprintf('%s still uses the deprecated %s directory for snippets. This directory is deprecated and will be removed in 1.7.2.', $projectName, $snippetsDir));
     }
     if ($foundNone) {
         $this->html->pInfo(sprintf('%s and %s are up to date.', $projectName, $escortClass));
     }
 }
 /**
  * Shows a support page
  */
 public function supportAction()
 {
     $this->initHtml();
     $this->html->h3($this->_('Support'));
     $this->html->pInfo()->sprintf($this->_('There is more than one way to get support for %s.'), $this->project->getName());
     if ($url = $this->project->getDocumentationUrl()) {
         $this->html->h4($this->_('Documentation'));
         $this->html->pInfo()->sprintf($this->_('All available documentation is gathered at: %s'))->a($url, array('rel' => 'external', 'target' => 'documentation'));
     }
     if ($url = $this->project->getManualUrl()) {
         $this->html->h4($this->_('Manual'));
         $this->html->pInfo()->sprintf($this->_('The manual is available here: %s'))->a($url, array('rel' => 'external', 'target' => 'manual'));
     }
     if ($url = $this->project->getForumUrl()) {
         $this->html->h4($this->_('The forum'));
         $this->html->pInfo()->sprintf($this->_('You will find questions asked by other users and ask new questions at our forum site: %s'))->a($url, array('rel' => 'external', 'target' => 'forum'));
     }
     if ($url = $this->project->getSupportUrl()) {
         $this->html->h4($this->_('Support site'));
         $this->html->pInfo()->sprintf($this->_('Check our support site at %s.'))->a($url, array('rel' => 'external', 'target' => 'support'));
     }
     $this->html->h4($this->_('Or contact'));
     $this->html->append($this->_getOrganizationsList());
 }
 /**
  * Creates a model for getModel(). Called only for each new $action.
  *
  * The parameters allow you to easily adapt the model to the current action. The $detailed
  * parameter was added, because the most common use of action is a split between detailed
  * and summarized actions.
  *
  * @param boolean $detailed True when the current action is not in $summarizedActions.
  * @param string $action The current action.
  * @return \MUtil_Model_ModelAbstract
  */
 protected function createModel($detailed, $action)
 {
     $dbLookup = $this->util->getDbLookup();
     $survey = null;
     $translated = $this->util->getTranslated();
     $yesNo = $translated->getYesNo();
     if ($detailed) {
         $surveyId = $this->_getIdParam();
         if ($surveyId) {
             $survey = $this->loader->getTracker()->getSurvey($surveyId);
         }
     }
     $model = new \Gems_Model_JoinModel('surveys', 'gems__surveys', 'gus');
     $model->addTable('gems__sources', array('gsu_id_source' => 'gso_id_source'));
     $model->setCreate(false);
     $model->addColumn("CASE WHEN gsu_survey_pdf IS NULL OR CHAR_LENGTH(gsu_survey_pdf) = 0 THEN 0 ELSE 1 END", 'gsu_has_pdf');
     $model->addColumn(sprintf("CASE WHEN (gsu_status IS NULL OR gsu_status = '') THEN '%s' ELSE gsu_status END", $this->_('OK')), 'gsu_status_show', 'gsu_status');
     $model->addColumn("CASE WHEN gsu_surveyor_active THEN '' ELSE 'deleted' END", 'row_class');
     $model->resetOrder();
     $model->set('gsu_survey_name', 'label', $this->_('Name'), 'elementClass', 'Exhibitor');
     $model->set('gsu_survey_description', 'label', $this->_('Description'), 'elementClass', 'Exhibitor', 'formatFunction', array(__CLASS__, 'formatDescription'));
     $model->set('gso_source_name', 'label', $this->_('Source'), 'elementClass', 'Exhibitor');
     $model->set('gsu_surveyor_active', 'label', $this->_('Active in source'), 'elementClass', 'Exhibitor', 'multiOptions', $yesNo);
     $model->set('gsu_status_show', 'label', $this->_('Status in source'), 'elementClass', 'Exhibitor');
     $model->set('gsu_active', 'label', sprintf($this->_('Active in %s'), $this->project->getName()), 'elementClass', 'Checkbox', 'multiOptions', $yesNo);
     $model->set('gsu_id_primary_group', 'label', $this->_('Group'), 'description', $this->_('If empty, survey will never show up!'), 'multiOptions', $dbLookup->getGroups());
     if ($detailed) {
         $model->addDependency('CanEditDependency', 'gsu_surveyor_active', array('gsu_active'));
         $model->set('gsu_active', 'validators[group]', new \MUtil_Validate_Require($model->get('gsu_active', 'label'), 'gsu_id_primary_group', $model->get('gsu_id_primary_group', 'label')));
     }
     $model->set('gsu_insertable', 'label', $this->_('Insertable'), 'description', $this->_('Can this survey be manually inserted into a track?'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo, 'onclick', 'this.form.submit()');
     if ($detailed) {
         $model->set('gsu_valid_for_length', 'label', $this->_('Add to inserted end date'), 'description', $this->_('Add to the start date to calculate the end date when inserting.'), 'filter', 'Int');
         $model->set('gsu_valid_for_unit', 'label', $this->_('Inserted end date unit'), 'description', $this->_('The unit used to calculate the end date when inserting the survey.'), 'multiOptions', $translated->getPeriodUnits());
         $model->set('gsu_insert_organizations', 'label', $this->_('Insert organizations'), 'description', $this->_('The organizations where the survey may be inserted.'), 'elementClass', 'MultiCheckbox', 'multiOptions', $dbLookup->getOrganizations(), 'required', true);
         $ct = new \MUtil_Model_Type_ConcatenatedRow('|', $this->_(', '));
         $ct->apply($model, 'gsu_insert_organizations');
         //            if ('edit' == $action) {
         //                $element = new \Gems_JQuery_Form_Element_ToggleCheckboxes('toggleOrg', array('selector'=>'input[name^=gtr_organizations]'));
         //                $element->setLabel($this->_('Toggle'));
         //                $model->set('toggleOrg', 'elementClass', $element);
         //            }
         $switches = array(0 => array('gsu_valid_for_length' => array('elementClass' => 'Hidden', 'label' => null), 'gsu_valid_for_unit' => array('elementClass' => 'Hidden', 'label' => null), 'gsu_insert_organizations' => array('elementClass' => 'Hidden', 'label' => null)));
         $model->addDependency(array('ValueSwitchDependency', $switches), 'gsu_insertable');
     }
     if ($detailed) {
         $model->set('track_usage', 'label', $this->_('Usage'), 'elementClass', 'Exhibitor', 'noSort', true, 'no_text_search', true);
         $model->setOnLoad('track_usage', array($this, 'calculateTrackUsage'));
         $model->set('calc_duration', 'label', $this->_('Duration calculated'), 'elementClass', 'Html');
         $model->setOnLoad('calc_duration', array($this, 'calculateDuration'));
         $model->set('gsu_duration', 'label', $this->_('Duration description'), 'description', $this->_('Text to inform the respondent, e.g. "20 seconds" or "1 minute".'));
         if ($survey instanceof \Gems_Tracker_Survey) {
             $surveyFields = $this->util->getTranslated()->getEmptyDropdownArray() + $survey->getQuestionList($this->locale->getLanguage());
             $model->set('gsu_result_field', 'label', $this->_('Result field'), 'multiOptions', $surveyFields);
             // $model->set('gsu_agenda_result',         'label', $this->_('Agenda field'));
         }
     } else {
         $model->set('track_count', 'label', ' ', 'elementClass', 'Exhibitor', 'noSort', true, 'no_text_search', true);
         $model->setOnLoad('track_count', array($this, 'calculateTrackCount'));
     }
     $model->set('gsu_code', 'label', $this->_('Survey code'), 'description', $this->_('Optional code name to link the survey to program code.'), 'size', 10);
     $model->set('gsu_export_code', 'label', $this->_('Survey export code'), 'description', $this->_('A unique code indentifying this survey during track import'), 'size', 20);
     if ($detailed) {
         $events = $this->loader->getEvents();
         $beforeOptions = $events->listSurveyBeforeAnsweringEvents();
         if (count($beforeOptions) > 1) {
             $model->set('gsu_beforeanswering_event', 'label', $this->_('Before answering'), 'multiOptions', $beforeOptions, 'elementClass', 'Select');
         }
         $completedOptions = $events->listSurveyCompletionEvents();
         if (count($completedOptions) > 1) {
             $model->set('gsu_completed_event', 'label', $this->_('After completion'), 'multiOptions', $completedOptions, 'elementClass', 'Select');
         }
         $displayOptions = $events->listSurveyDisplayEvents();
         if (count($displayOptions) > 1) {
             $model->set('gsu_display_event', 'label', $this->_('Answer display'), 'multiOptions', $displayOptions, 'elementClass', 'Select');
         }
         if ('show' !== $action || $survey->hasPdf()) {
             // Only the action changes from the current page
             // and the right to see the pdf is the same as
             // the right to see this page.
             $pdfLink = \MUtil_Html::create('a', array($this->getRequest()->getActionKey() => 'pdf'), array('class' => 'pdf', 'target' => '_blank', 'type' => 'application/pdf', 'onclick' => 'event.cancelBubble = true;'));
             $model->set('gsu_survey_pdf', 'label', 'Pdf', 'accept', 'application/pdf', 'destination', $this->loader->getPdf()->getUploadDir('survey_pdfs'), 'elementClass', 'File', 'extension', 'pdf', 'filename', $surveyId, 'required', false, 'itemDisplay', $pdfLink, 'validators[pdf]', new \MUtil_Validate_Pdf());
         }
     }
     return $model;
 }