/** * 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 */ public function createModel($detailed, $action) { $currentLanguage = $this->locale->getLanguage(); $model = $this->loader->getModels()->getCommtemplateModel($currentLanguage); $commTargets = $this->loader->getMailTargets(); $model->set('gct_target', 'label', $this->_('Mail Target'), 'multiOptions', $commTargets, 'Gems_Default_CommTemplateAction', 'translateTargets'); $model->set('gct_name', 'label', $this->_('Name'), 'size', 50); $translationModel = new \MUtil_Model_TableModel('gems__comm_template_translations', 'gctt'); if ($action === 'index') { $translationModel->set('gctt', 'label', $this->_('Subject'), 'size', 50, 'formatFunction', array('Gems_Default_CommTemplateAction', 'displayMultipleSubjects')); } else { $translationModel->set('gctt_subject', 'label', $this->_('Subject'), 'size', 50); } if ($detailed) { $translationModel->set('gctt_body', 'label', $this->_('Message'), 'elementClass', 'textarea', 'decorators', array('CKEditor'), 'rows', 4, 'formatFunction', array('Gems_Default_CommTemplateAction', 'bbToHtml')); } if ($this->project->getEmailMultiLanguage()) { $allLanguages = $this->util->getLocalized()->getLanguages(); ksort($allLanguages); $requiredRows = array(); foreach ($allLanguages as $code => $language) { $requiredRows[]['gctt_lang'] = $code; } } else { $defaultLanguage = $this->project->getLocaleDefault(); $requiredRows[]['gctt_lang'] = $defaultLanguage; $translationModel->setFilter(array('gctt_lang' => $defaultLanguage)); } $model->set('gct_code', 'label', $this->_('Template code'), 'size', 50, 'description', $this->_('Optional code name to link the template to program code.')); $transformer = new \MUtil_Model_Transform_RequiredRowsTransformer(); $transformer->setRequiredRows($requiredRows); $translationModel->addTransformer($transformer); $model->addModel($translationModel, array('gct_id_template' => 'gctt_id_template'), 'gctt'); return $model; }
/** * 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 */ public function createModel($detailed, $action) { $rcLib = $this->util->getReceptionCodeLibrary(); $yesNo = $this->util->getTranslated()->getYesNo(); $model = new \MUtil_Model_TableModel('gems__reception_codes'); $model->copyKeys(); // The user can edit the keys. $model->set('grc_id_reception_code', 'label', $this->_('Code'), 'size', '10'); $model->set('grc_description', 'label', $this->_('Description'), 'size', '30'); $model->set('grc_success', 'label', $this->_('Is success code'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('This reception code is a success code.')); $model->set('grc_active', 'label', $this->_('Active'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('Only active codes can be selected.')); if ($detailed) { $model->set('desc1', 'elementClass', 'Html', 'label', ' ', 'value', \MUtil_Html::create('h4', $this->_('Can be assigned to'))); } $model->set('grc_for_respondents', 'label', $this->_('Respondents'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('This reception code can be assigned to a respondent.')); $model->set('grc_for_tracks', 'label', $this->_('Tracks'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('This reception code can be assigned to a track.')); $model->set('grc_for_surveys', 'label', $this->_('Tokens'), 'multiOptions', $rcLib->getSurveyApplicationValues(), 'description', $this->_('This reception code can be assigned to a token.')); if ($detailed) { $model->set('desc2', 'elementClass', 'Html', 'label', ' ', 'value', \MUtil_Html::create('h4', $this->_('Additional actions'))); } $model->set('grc_redo_survey', 'label', $this->_('Redo survey'), 'multiOptions', $rcLib->getRedoValues(), 'description', $this->_('Redo a survey on this reception code.')); $model->set('grc_overwrite_answers', 'label', $this->_('Overwrite existing consents'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('Remove the consent from already answered surveys.')); if ($detailed) { $model->set('grc_id_reception_code', 'validator', $model->createUniqueValidator('grc_id_reception_code')); $model->set('grc_description', 'validator', $model->createUniqueValidator('grc_description')); } if ($this->project->multiLocale) { $model->set('grc_description', 'description', 'ENGLISH please! Use translation file to translate.'); } \Gems_Model::setChangeFieldsByPrefix($model, 'grc'); return $model; }
/** * 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) { $translated = $this->util->getTranslated(); $model = new \MUtil_Model_TableModel('gems__tracks'); $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gtr_survey_rounds', 'label', $this->_('Survey #')); $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', $translated->formatDate, 'tdClass', 'date'); $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', $translated->formatDateForever, 'tdClass', 'date'); return $model; }
/** * Create the model * * @return MUtil_Model_ModelAbstract */ protected function getModel() { if (!$this->_model) { $this->_model = new MUtil_Model_TableModel('gems__respondents'); $this->_model->set('grs_birthday', 'storageFormat', 'yyyy-MM-dd'); $this->_model->set('grs_birthday', 'dateFormat', Zend_Date::DATE_MEDIUM); $this->_model->setOnSave('grs_birthday', array($this->_model, 'formatSaveDate')); $this->_model->setOnLoad('grs_birthday', array($this->_model, 'formatLoadDate')); } return $this->_model; }
/** * 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 */ public function createModel($detailed, $action) { $model = new \MUtil_Model_TableModel('gems__groups'); // Add id for excel export if ($action == 'excel') { $model->set('ggp_id_group', 'label', 'id'); } $model->set('ggp_name', 'label', $this->_('Name'), 'size', 15, 'minlength', 4, 'validator', $model->createUniqueValidator('ggp_name')); $model->set('ggp_description', 'label', $this->_('Description'), 'size', 40); $model->set('ggp_role', 'label', $this->_('Role'), 'multiOptions', $this->util->getDbLookup()->getRoles()); $yesNo = $this->util->getTranslated()->getYesNo(); $model->set('ggp_group_active', 'label', $this->_('Active'), 'multiOptions', $yesNo, 'elementClass', 'Checkbox'); $model->set('ggp_staff_members', 'label', $this->_('Staff'), 'multiOptions', $yesNo, 'elementClass', 'Checkbox'); $model->set('ggp_respondent_members', 'label', $this->_('Respondents'), 'multiOptions', $yesNo, 'elementClass', 'Checkbox'); $model->set('ggp_allowed_ip_ranges', 'label', $this->_('Allowed IP Ranges'), 'description', $this->_('Separate with | example: 10.0.0.0-10.0.0.255 (subnet masks are not supported)'), 'size', 50, 'validator', new \Gems_Validate_IPRanges(), 'maxlength', 500); \Gems_Model::setChangeFieldsByPrefix($model, 'ggp'); return $model; }
/** * 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 */ public function createModel($detailed, $action) { $model = new \MUtil_Model_TableModel('gems__consents'); $model->copyKeys(); // The user can edit the keys. $model->set('gco_description', 'label', $this->_('Description'), 'size', '10'); $model->set('gco_order', 'label', $this->_('Order'), 'size', '10', 'description', $this->_('Determines order of presentation in interface.'), 'validator', 'Digits'); $model->set('gco_code', 'label', $this->_('Consent code'), 'multiOptions', $this->util->getConsentTypes(), 'description', $this->_('Internal code, not visible to users, copied with the token information to the source.')); if ($detailed) { $model->set('gco_description', 'validator', $model->createUniqueValidator('gco_description')); $model->set('gco_order', 'validator', $model->createUniqueValidator('gco_order')); } if ($this->project->multiLocale) { $model->set('gco_description', 'description', 'ENGLISH please! Use translation file to translate.'); } \Gems_Model::setChangeFieldsByPrefix($model, 'gco'); return $model; }
/** * 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 */ public function createModel($detailed, $action) { $tracker = $this->loader->getTracker(); $model = new \MUtil_Model_TableModel('gems__sources'); $model->set('gso_source_name', 'label', $this->_('Name'), 'description', $this->_('E.g. the name of the project - for single source projects.'), 'size', 15, 'minlength', 4, 'validator', $model->createUniqueValidator('gso_source_name')); $model->set('gso_ls_url', 'label', $this->_('Source Url'), 'default', 'http://', 'description', $this->_('For creating token-survey url.'), 'size', 50, 'validators[unique]', $model->createUniqueValidator('gso_ls_url'), 'validators[url]', new \MUtil_Validate_Url()); $sourceClasses = $tracker->getSourceClasses(); end($sourceClasses); $model->set('gso_ls_class', 'label', $this->_('Adaptor class'), 'default', key($sourceClasses), 'multiOptions', $sourceClasses); $model->set('gso_ls_adapter', 'label', $this->_('Database Server'), 'default', substr(get_class($this->db), strlen('Zend_Db_Adapter_')), 'description', $this->_('The database server used by the source.'), 'multiOptions', $tracker->getSourceDatabaseClasses()); $model->set('gso_ls_table_prefix', 'label', $this->_('Table prefix'), 'default', 'ls__', 'description', $this->_('Do not forget the underscores.'), 'size', 15); if ($detailed) { $in_gems = $this->_('Leave empty for the Gems database.'); $model->set('gso_ls_dbhost', 'label', $this->_('Database host'), 'description', $in_gems, 'size', 15); $model->set('gso_ls_database', 'label', $this->_('Database'), 'description', $in_gems, 'size', 15); $model->set('gso_ls_username', 'label', $this->_('Database Username'), 'description', $in_gems, 'size', 15); $model->set('gso_ls_password', 'label', $this->_('Database Password'), 'elementClass', 'Password', 'repeatLabel', $this->_('Repeat password'), 'required', false, 'size', 15); if ('create' == $action) { $model->set('gso_ls_password', 'description', $in_gems, 'renderPassword', true); } else { $model->set('gso_ls_password', 'description', $this->_('Enter only when changing'), 'renderPassword', false); } $type = new \Gems_Model_Type_EncryptedField($this->project, true); $type->apply($model, 'gso_ls_password', 'gso_encryption'); $model->set('gso_ls_charset', 'label', $this->_('Charset'), 'description', $in_gems, 'size', 15); $model->set('gso_active', 'label', $this->_('Active'), 'default', 0, 'multiOptions', $this->util->getTranslated()->getYesNo()); } $model->set('gso_status', 'label', $this->_('Status'), 'default', 'Not checked', 'elementClass', 'Exhibitor'); $model->set('gso_last_synch', 'label', $this->_('Last synchronisation'), 'elementClass', 'Exhibitor'); \Gems_Model::setChangeFieldsByPrefix($model, 'gso'); return $model; }
/** * 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 */ public function createModel($detailed, $action) { $model = new \MUtil_Model_TableModel('gems__roles'); $model->set('grl_name', 'label', $this->_('Name'), 'size', 15, 'minlength', 4); $model->set('grl_description', 'label', $this->_('Description'), 'size', 40); $model->set('grl_parents', 'label', $this->_('Parents')); $tpa = new \MUtil_Model_Type_ConcatenatedRow(',', ', '); $tpa->apply($model, 'grl_parents'); $model->setOnLoad('grl_parents', array(\Gems_Roles::getInstance(), 'translateToRoleNames')); $model->set('grl_privileges', 'label', $this->_('Privileges')); $tpr = new \MUtil_Model_Type_ConcatenatedRow(',', '<br/>'); $tpr->apply($model, 'grl_privileges'); if ($detailed) { $model->set('grl_name', 'validators[unique]', $model->createUniqueValidator('grl_name'), 'validators[nomaster]', new \MUtil_Validate_IsNot('master', $this->_('The name "master" is reserved'))); $model->set('grl_privileges', 'formatFunction', array($this, 'formatPrivileges')); if ('show' === $action) { $model->addColumn('grl_parents', 'inherited'); $tpa->apply($model, 'inherited'); $model->set('inherited', 'label', $this->_('Inherited privileges'), 'formatFunction', array($this, 'formatInherited')); $model->setOnLoad('inherited', array(\Gems_Roles::getInstance(), 'translateToRoleNames')); // Concatenated field, we can not use onload so handle transaltion to rolenames in the formatFunction $model->addColumn("CONCAT(COALESCE(grl_parents, ''), '\t', COALESCE(grl_privileges, ''))", 'not_allowed'); $model->set('not_allowed', 'label', $this->_('Not allowed'), 'formatFunction', array($this, 'formatNotAllowed')); } } else { $model->set('grl_privileges', 'formatFunction', array($this, 'formatLongLine')); } \Gems_Model::setChangeFieldsByPrefix($model, 'grl'); return $model; }