예제 #1
0
 protected function doSave($con = null)
 {
     $message = parent::doSave($con);
     $message = $this->getObject();
     /* // Ajout des infos concernant la réservation lors de l'envoi du message
     		$message->setText("TEST REUSSI\n\n\n--------------------\n\n\n".$message->getText()); */
     $recipient = $message->getRecipientUser();
     $to = $recipient->getEmailAddress();
     $sender = $message->getSenderUser();
     $from = null;
     if (ConfigurationHelper::getParameter('Email', 'use_mail', false)) {
         if (!empty($to)) {
             if (!is_null($sender)) {
                 $from = $sender->getEmailAddress();
                 if (empty($from)) {
                     $from = null;
                 }
             }
             MailHelper::send($to, $message->getSubject(), $message->getText(), $recipient->getFullName(), $from, $message->getSender());
         }
     }
     if (!is_null($sender)) {
         $messageSent = $message->copy();
         $messageSent->setOwnerId($sender->getId());
         $messageSent->setWasRead(true);
         $messageSent->save();
     }
     return $message;
 }
예제 #2
0
 public function configure()
 {
     // Sort
     $activitySortCriteria = new Criteria();
     $activitySortCriteria->addAscendingOrderByColumn(ActivityPeer::NAME);
     $userSortCriteria = new Criteria();
     $userSortCriteria->addAscendingOrderByColumn(UserPeer::FAMILY_NAME);
     // Remove some fields
     //unset($this['usergroup_has_chief_list']);
     // Labels
     $activityItem = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityItem) || empty($activityItem)) {
         $activityItem = 'Activities';
     }
     $this->widgetSchema->setLabel('usergroup_has_chief_list', 'Leader(s)');
     $this->widgetSchema->setLabel('usergroup_has_user_list', 'Member(s)');
     $this->widgetSchema->setLabel('usergroup_has_activity_list', $activityItem);
     // Validators
     $this->validatorSchema['name'] = new sfXSSValidatorString(array('max_length' => 64));
     // Options
     $this->widgetSchema['usergroup_has_chief_list']->setOption('expanded', true);
     $this->widgetSchema['usergroup_has_chief_list']->setOption('criteria', $userSortCriteria);
     $this->validatorSchema['usergroup_has_chief_list']->setOption('required', true);
     $this->widgetSchema['usergroup_has_user_list']->setOption('expanded', true);
     $this->widgetSchema['usergroup_has_user_list']->setOption('criteria', $userSortCriteria);
     $this->widgetSchema['usergroup_has_activity_list']->setOption('expanded', true);
     $this->widgetSchema['usergroup_has_activity_list']->setOption('criteria', $activitySortCriteria);
     $this->validatorSchema['usergroup_has_activity_list']->setOption('required', true);
 }
예제 #3
0
 /**
  * Deletes a message type.
  *
  * @param   integer  $pk  Primary key of the message type to be deleted.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function delete($pk = null)
 {
     // Add configuration helper file
     require_once JPATH_COMPONENT . '/helpers/configuration.php';
     // If message type is defined as default in configuration, it cannot be removed
     if (ConfigurationHelper::isMessageTypeUsedInConfiguration($this->id)) {
         // Raise a warning
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_MESSAGE_TYPE_DELETE_FAILED_SETTINGS'), 'warning');
         // Return false as the item can't be deleted
         return false;
     }
     // Load message template model
     $messageTemplateModel = JModelLegacy::getInstance('messagetemplate', 'IssnregistryModel');
     // Get number of templates that use this message type
     $templateCount = $messageTemplateModel->getMessageTemplatesCountByMessageType($this->id);
     // If template count is not zero, message type cannot be deleted
     if ($templateCount != 0) {
         // Raise a warning
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_MESSAGE_TYPE_DELETE_FAILED_USED'), 'warning');
         // Return false as the item can't be deleted
         return false;
     }
     // No ISSNs have been used, delete the item
     return parent::delete($pk);
 }
예제 #4
0
 protected function execute($arguments = array(), $options = array())
 {
     $this->configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $this->context = sfContext::createInstance($this->configuration);
     $databaseManager = new sfDatabaseManager($this->configuration);
     $dbdsn = $databaseManager->getDatabase('propel')->getParameter('dsn');
     $dbusername = $databaseManager->getDatabase('propel')->getParameter('username');
     $dbpassword = $databaseManager->getDatabase('propel')->getParameter('password');
     $dbname = preg_replace('/^.*dbname=([^;=]+).*$/', '${1}', $dbdsn);
     ConfigurationHelper::load();
     $backup_method = ConfigurationHelper::getParameter('Backup', 'backup_method');
     $this->logSection('tempos', sprintf('Backup method: %s', $backup_method), 1024);
     if ($backup_method == 'ftp') {
         $backupname = 'tempos-backup.sql';
         $configname = ConfigurationHelper::getDefaultConfigurationFileName();
         $configpath = ConfigurationHelper::getDefaultConfigurationFilePath();
         copy($configpath, '/tmp/' . $configname);
         chdir('/tmp');
         system(sprintf('mysqldump --user=%s --password=%s %s > %s', escapeshellarg($dbusername), escapeshellarg($dbpassword), escapeshellarg($dbname), escapeshellarg($backupname)));
         $tmpfilename = 'tempos-backup-' . date('Y-m-d') . '.tar.gz';
         system(sprintf('tar zcf %s %s %s', escapeshellarg($tmpfilename), escapeshellarg($backupname), escapeshellarg($configname)));
         unlink($backupname);
         unlink($configname);
         try {
             FTPHelper::backupFile($tmpfilename);
         } catch (Exception $ex) {
             unlink($tmpfilename);
             throw $ex;
         }
         unlink($tmpfilename);
     }
 }
예제 #5
0
 public function configure()
 {
     $pac_list = array();
     $choices = array();
     // Recherche les différents contrôleurs d'accès physiques
     for ($i = 1; $i <= ConfigurationHelper::getParameter(null, 'number_of_physical_access'); $i++) {
         $pac_list[] = ConfigurationHelper::getParameter(null, 'physical_access_controller' . $i);
     }
     $i = 1;
     // Recherche les noms données aux différents contrôleurs
     foreach ($pac_list as $pac) {
         $choices[] = ConfigurationHelper::getParameter($pac . $i, 'controller_name');
         $i++;
     }
     // Widgets
     if (count($choices) > 0) {
         $this->widgetSchema['physical_access_controller'] = new sfWidgetFormChoice(array('choices' => $choices, 'expanded' => false));
     }
     // Validators
     $this->validatorSchema['physical_access_controller'] = new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => false));
     $this->validatorSchema['name'] = new sfXSSValidatorString(array('max_length' => 256));
     $this->validatorSchema['physical_access_id'] = new sfXSSValidatorString(array('max_length' => 256));
     // Labels
     $this->widgetSchema->setLabel('physical_access_id', 'Physical access identifier');
     if (count($choices) > 0) {
         $this->widgetSchema->setLabel('physical_access_controller', 'Configured Physical Access Controller');
     }
 }
 public function filter($values)
 {
     if (empty($values['ftp_password']) && ConfigurationHelper::hasParameter('Backup', 'ftp_password')) {
         $values['ftp_password'] = ConfigurationHelper::getParameter('Backup', 'ftp_password');
     }
     return $values;
 }
 public function configure()
 {
     // Sort
     $activitySortCriteria = new Criteria();
     $activitySortCriteria->addAscendingOrderByColumn(ActivityPeer::NAME);
     // Choices
     $userTypeChoices = array(self::EVERYBODY => sfContext::getInstance()->getI18N()->__('Everybody'), self::LEADERS => sfContext::getInstance()->getI18N()->__('Leaders'), self::MEMBERS => sfContext::getInstance()->getI18N()->__('Members'), self::NONMEMBERS => sfContext::getInstance()->getI18N()->__('Non-members'));
     $createRuleChoices = array(self::ADD => sfContext::getInstance()->getI18N()->__('Add'), self::REPLACE => sfContext::getInstance()->getI18N()->__('Replace'), self::FILL => sfContext::getInstance()->getI18N()->__('Fill'), self::DELETE => sfContext::getInstance()->getI18N()->__('Delete'));
     // Layout
     $this->widgetSchema['User_type'] = new sfWidgetFormChoice(array('choices' => $userTypeChoices));
     $this->widgetSchema['Create_rule'] = new sfWidgetFormChoice(array('choices' => $createRuleChoices));
     $this->widgetSchema['Activity_id']->setOption('expanded', true);
     $this->widgetSchema['Activity_id']->setOption('multiple', true);
     $this->widgetSchema['Activity_id']->setOption('criteria', $activitySortCriteria);
     $this->widgetSchema['Zone_id'] = new sfWidgetFormZoneChoice(array('multiple' => true, 'add_empty' => false));
     $this->widgetSchema['unlimitedCredit'] = new sfWidgetFormInputCheckbox();
     $this->widgetSchema['UserGroup_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['User_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['Card_id'] = new sfWidgetFormInputHidden();
     $years = range(date('Y') - 128, date('Y') + 128);
     $this->widgetSchema['start']->setOption('years', array_combine($years, $years));
     $this->widgetSchema['stop']->setOption('years', array_combine($years, $years));
     // Labels
     $activityLabel = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityLabel) || empty($activityLabel)) {
         $activityLabel = 'Activity';
     }
     $this->widgetSchema->setLabel('User_type', 'Edit for');
     $this->widgetSchema->setLabel('Create_rule', 'Edition rule');
     $this->widgetSchema->setLabel('Activity_id', $activityLabel);
     $this->widgetSchema->setLabel('Zone_id', 'Zone');
     $this->widgetSchema->setLabel('UserGroup_id', 'Group');
     $this->widgetSchema->setLabel('unlimitedCredit', 'Unlimited access');
     $this->widgetSchema->setLabel('minimum_delay', 'Minimum number of hours in advance');
     $this->widgetSchema->setLabel('maximum_delay', 'Maximum number of days in advance');
     $this->widgetSchema->setLabel('minimum_duration', 'Minimum duration of reservations (minutes)');
     $this->widgetSchema->setLabel('maximum_duration', 'Maximum duration of reservations (minutes)');
     $this->widgetSchema->setLabel('hours_per_week', 'How many hours allowed per week (hours)');
     // Validators
     $step = sfConfig::get('app_booking_step');
     $this->validatorSchema['User_type'] = new sfValidatorChoice(array('choices' => array_keys($userTypeChoices), 'required' => true));
     $this->validatorSchema['Create_rule'] = new sfValidatorChoice(array('choices' => array_keys($createRuleChoices), 'required' => true));
     $this->validatorSchema['credit']->setOption('min', 1);
     $this->validatorSchema['Activity_id']->setOption('multiple', true);
     $this->validatorSchema['Zone_id']->setOption('multiple', true);
     $this->validatorSchema['unlimitedCredit'] = new sfValidatorBoolean(array('required' => false));
     $this->validatorSchema['minimum_delay']->setOption('min', 0);
     $this->validatorSchema['maximum_delay']->setOption('min', 0);
     $this->validatorSchema['minimum_duration']->setOption('min', $step);
     $this->validatorSchema['maximum_duration']->setOption('min', $step);
     $this->validatorSchema['hours_per_week']->setOption('min', 1);
     //$this->validatorSchema['hours_per_week']->setOption('max', 170);
     // Defaults
     $this->setDefault('Create_rule', self::REPLACE);
     $this->setDefault('start', strftime("%Y-%m-%d", time()));
     $this->setDefault('stop', strftime("%Y-%m-%d", strtotime('+1 year')));
     $this->setDefault('unlimitedCredit', true);
     // Post validators
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorSchemaCompare('stop', sfValidatorSchemaCompare::GREATER_THAN, 'start', array(), array('invalid' => 'The stop date must be after the start date.')), new sfValidatorSchemaCompare('maximum_duration', sfValidatorSchemaCompare::GREATER_THAN, 'minimum_duration', array(), array('invalid' => 'The maximum duration must be greater than the minimum duration.')))));
 }
예제 #8
0
 public function executeMenu()
 {
     if ($this->getUser()->isAuthenticated()) {
         $this->modules = array();
         $this->modules['home'] = __('Home');
         if ($this->getUser()->hasCredential(array('admin', 'userManager'), false)) {
             $this->modules['user'] = __('Users');
             $this->modules['card'] = __('Cards');
         }
         if ($this->getUser()->hasCredential(array('admin', 'zoneManager'), false)) {
             $this->modules['zone'] = __('Zones');
         }
         if ($this->getUser()->hasCredential(array('admin', 'activityManager'), false)) {
             $activityModule = ConfigurationHelper::getParameter('Rename', 'activity_module');
             if (is_null($activityModule) || empty($activityModule)) {
                 $activityModule = 'Activities';
             }
             $this->modules['activity'] = __($activityModule);
         }
         if ($this->getUser()->hasCredential(array('admin', 'reportingManager'), false)) {
             $this->modules['reporting'] = __('Tools');
         }
         if ($this->getUser()->hasCredential(array('admin'), false)) {
             $this->modules['energyaction'] = __('Energy');
         }
     }
 }
예제 #9
0
 public function configure()
 {
     unset($this['room_has_dayperiod_list']);
     unset($this['room_has_featurevalue_list']);
     // Sort
     $activitySortCriteria = new Criteria();
     $activitySortCriteria->addAscendingOrderByColumn(ActivityPeer::NAME);
     $energyactionSortCriteria = new Criteria();
     $energyactionSortCriteria->addAscendingOrderByColumn(EnergyactionPeer::NAME);
     // Layout
     $this->widgetSchema['address'] = new sfWidgetFormInputGeoComplete();
     $this->widgetSchema['description'] = new sfWidgetFormTextarea();
     $this->widgetSchema['room_has_activity_list']->setOption('expanded', true);
     $this->widgetSchema['room_has_activity_list']->setOption('criteria', $activitySortCriteria);
     $this->widgetSchema['room_has_energyaction_list']->setOption('criteria', $energyactionSortCriteria);
     $this->widgetSchema['zone_has_room_list'] = new sfWidgetFormZoneChoice(array('multiple' => true, 'add_empty' => false));
     $this->widgetSchema['room_has_energyaction_list']->setOption('expanded', true);
     // Validators
     $this->validatorSchema['capacity']->setOption('min', 1);
     $this->validatorSchema['zone_has_room_list']->setOption('required', true);
     $this->validatorSchema['name'] = new sfXSSValidatorString(array('max_length' => 64));
     // Labels
     $activityItem = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityItem) || empty($activityItem)) {
         $activityItem = 'Activities';
     }
     $this->widgetSchema->setLabel('room_has_activity_list', $activityItem);
     $this->widgetSchema->setLabel('zone_has_room_list', 'Zones');
     $this->widgetSchema->setLabel('room_has_energyaction_list', 'Energy actions');
     // Post-validators
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorPropelUnique(array('model' => 'Room', 'column' => array('name'))))));
 }
 static function InstanceClass()
 {
     if (!isset(self::$mrInstance)) {
         self::$mrInstance = new ConfigurationHelper();
     }
     return self::$mrInstance;
 }
 public function configure()
 {
     $this->widgetSchema['allow_registration'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['allow_registration'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('allow_registration', 'Allow registration');
     $this->widgetSchema['registration_granted_message'] = new sfWidgetFormTextarea();
     $this->validatorSchema['registration_granted_message'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('registration_granted_message', 'Registration granted message');
     $this->widgetSchema['subtitle'] = new sfWidgetFormInput();
     $this->validatorSchema['subtitle'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('subtitle', 'Subtitle');
     $this->widgetSchema['auth_ldap_choice'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['auth_ldap_choice'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('auth_ldap_choice', 'Use LDAP authentication');
     $this->widgetSchema['auth_ldap_host'] = new sfWidgetFormInput();
     $this->validatorSchema['auth_ldap_host'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('auth_ldap_host', 'LDAP Host');
     $this->widgetSchema['auth_ldap_domain'] = new sfWidgetFormInput();
     $this->validatorSchema['auth_ldap_domain'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('auth_ldap_domain', 'LDAP Domain name');
     // Enabled by default
     if (!ConfigurationHelper::hasParameter('General', 'allow_registration')) {
         ConfigurationHelper::setParameter('General', 'allow_registration', true);
     }
     // Disabled by default
     if (!ConfigurationHelper::hasParameter('General', 'auth_ldap_choice')) {
         ConfigurationHelper::setParameter('General', 'auth_ldap_choice', false);
     }
     $this->setDefaults(ConfigurationHelper::getNamespace('General'));
     $this->widgetSchema->setNameFormat('generalConfiguration[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
 }
 protected function writeInterfaces()
 {
     $network_interface = sfConfig::get('app_network_interface');
     $default_network_interfaces_file = sfConfig::get('app_default_network_interfaces_file', '/etc/network/interfaces');
     $values = ConfigurationHelper::getNamespace('Network');
     $ipv4_type = $values['ipv4_type'];
     if (empty($network_interface)) {
         $this->logSection('tempos', 'No network interface defined in app.yml !', 1024, 'ERROR');
         return false;
     }
     if (!is_writeable($default_network_interfaces_file)) {
         $this->logSection('tempos', sprintf('Cannot write to "%s".', $default_network_interfaces_file), 1024, 'ERROR');
         return false;
     }
     $this->logSection('tempos', sprintf('IPv4 type is: "%s".', $ipv4_type), 1024);
     if ($ipv4_type == 'system') {
         $this->logSection('tempos', 'Nothing to do.', 1024);
         return true;
     }
     $template = array();
     $template[] = sprintf('iface %s inet %s', $network_interface, $ipv4_type);
     if ($ipv4_type == 'static') {
         $ipv4_address = $values['ipv4_address'];
         $ipv4_netmask = $values['ipv4_netmask'];
         $ipv4_gateway = $values['ipv4_gateway'];
         $template[] = sprintf("\taddress %s", $ipv4_address);
         $template[] = sprintf("\tnetmask %s", $ipv4_netmask);
         $template[] = sprintf("\tgateway %s", $ipv4_gateway);
     }
     $template[] = "";
     $template[] = "";
     $file = file($default_network_interfaces_file);
     $newfile = array();
     $add_mode = true;
     foreach ($file as $line) {
         if ($add_mode) {
             if (preg_match(sprintf('/^[\\t]*iface[ \\t]+%s/', $network_interface), $line)) {
                 $add_mode = false;
                 $newfile[] = implode("\n", $template);
             } else {
                 $newfile[] = $line;
             }
         } else {
             if (preg_match('/^[ \\t]*(iface|mapping|auto|allow-)/', $line)) {
                 $add_mode = true;
                 $newfile[] = $line;
             }
         }
     }
     $fp = fopen($default_network_interfaces_file, 'w');
     if ($fp) {
         fwrite($fp, implode('', $newfile));
         fclose($fp);
     } else {
         $this->logSection('tempos', sprintf('Cannot open "%s" for writing.', $default_network_interfaces_file), 1024, 'ERROR');
         return false;
     }
     return true;
 }
예제 #13
0
 public function configure()
 {
     $hac_list = array();
     $choices = array();
     $nb_hac = ConfigurationHelper::getParameter(null, 'number_of_home_automation');
     // Recherche les différents contrôleurs d'accès physiques
     if ($nb_hac > 0) {
         for ($i = 1; $i <= $nb_hac; $i++) {
             $hac_list[] = ConfigurationHelper::getParameter(null, 'home_automation_controller' . $i);
         }
     }
     $i = 1;
     // Recherche les noms données aux différents contrôleurs
     foreach ($hac_list as $hac) {
         $choices[] = ConfigurationHelper::getParameter($hac . $i, 'controller_name');
         $i++;
     }
     // Widgets
     if (count($choices) > 0) {
         $this->widgetSchema['home_automation_controller'] = new sfWidgetFormChoice(array('choices' => $choices, 'expanded' => false));
     }
     // Layout
     unset($this['status']);
     $this->widgetSchema['room_has_energyaction_list']->setOption('expanded', true);
     // Validators
     $this->validatorSchema['home_automation_controller'] = new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => false));
     $this->validatorSchema['name'] = new sfXSSValidatorString(array('max_length' => 64));
     // Labels
     if (count($choices) > 0) {
         $this->widgetSchema->setLabel('home_automation_controller', 'Configured Home Automation Controller');
     }
     $this->widgetSchema->setLabel('delayUp', 'Up delay (minutes)');
     $this->widgetSchema->setLabel('delayDown', 'Down delay (minutes)');
     $this->widgetSchema->setLabel('identifier', 'Identifier');
     $this->widgetSchema->setLabel('processIdUp', 'Up PID');
     $this->widgetSchema->setLabel('processIdDown', 'Down PID');
     $this->widgetSchema->setLabel('start', 'Start');
     $this->widgetSchema->setLabel('stop', 'Stop');
     $this->widgetSchema->setLabel('room_has_energyaction_list', 'Rooms');
     // Options
     $minutes = array();
     for ($i = 0; $i < 60; $i += 5) {
         $minutes[$i] = str_pad($i, 2, '0', STR_PAD_LEFT);
     }
     $this->widgetSchema['start']->setOption('minutes', $minutes);
     $this->widgetSchema['stop']->setOption('minutes', $minutes);
     // Defaults
     $this->setDefault('start', '20:00');
     $this->setDefault('stop', '08:00');
     // Validators
     $this->validatorSchema['delayUp']->setOption('min', 0);
     $this->validatorSchema['delayDown']->setOption('min', 0);
     // Post-validators
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorPropelUnique(array('model' => 'Energyaction', 'column' => array('name'))))));
 }
예제 #14
0
 public function configure()
 {
     // Layout
     unset($this['ReservationReason_id']);
     unset($this['status']);
     unset($this['created_at']);
     unset($this['updated_at']);
     unset($this['is_activated']);
     $this->widgetSchema['comment'] = new sfWidgetFormTextarea();
     $this->widgetSchema['UserGroup_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['User_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['Card_id'] = new sfWidgetFormInputHidden();
     // Options
     $this->widgetSchema['date']->setOption('time', array('minutes' => array(0 => '00', 30 => '30')));
     // Labels
     $this->widgetSchema->setLabel('RoomProfile_id', 'Physical access');
     $activityItem = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityItem) || empty($activityItem)) {
         $activityItem = 'Activity';
     }
     $this->widgetSchema->setLabel('Activity_id', $activityItem);
     $this->widgetSchema->setLabel('Card_id', 'Card');
     $this->widgetSchema->setLabel('User_id', 'User');
     $this->widgetSchema->setLabel('duration', 'Duration (minutes)');
     $this->widgetSchema->setLabel('date', 'Date and time');
     $this->widgetSchema->setLabel('members_count', 'Members count');
     $this->widgetSchema->setLabel('guests_count', 'Guests count');
     $this->widgetSchema->setLabel('price', 'Price');
     $this->widgetSchema->setLabel('reservation_has_user_list', 'Other member(s)');
     // Checking specific fields name
     $custom1 = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_1');
     $custom2 = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_2');
     $custom3 = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_3');
     $this->widgetSchema->setLabel('custom_1', empty($custom1) ? 'hide' : $custom1);
     $this->widgetSchema->setLabel('custom_2', empty($custom2) ? 'hide' : $custom2);
     $this->widgetSchema->setLabel('custom_3', empty($custom3) ? 'hide' : $custom3);
     $userSortCriteria = new Criteria();
     $userSortCriteria->addAscendingOrderByColumn(UserPeer::FAMILY_NAME);
     $this->widgetSchema['reservation_has_user_list']->setOption('expanded', true);
     $this->widgetSchema['reservation_has_user_list']->setOption('criteria', $userSortCriteria);
     // Validators
     $step = sfConfig::get('app_booking_step');
     $this->validatorSchema['RoomProfile_id']->setOption('required', true);
     $this->validatorSchema['duration']->setOption('min', $step);
     $this->validatorSchema['members_count']->setOption('min', 0);
     $this->validatorSchema['guests_count']->setOption('min', 0);
     // Defaults
     $this->setDefault('members_count', 0);
     $this->setDefault('guests_count', 0);
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(self::getReservationValidators()));
 }
예제 #15
0
 /**
  * Deletes a message template.
  *
  * @param   integer  $pk  Primary key of the message template to be deleted.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function delete($pk = null)
 {
     // Add configuration helper file
     require_once JPATH_COMPONENT . '/helpers/configuration.php';
     // If message template's message type is defined as default in
     // configuration, it cannot be removed
     if (ConfigurationHelper::isMessageTypeUsedInConfiguration($this->message_type_id)) {
         // Raise a warning
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_MESSAGE_TEMPLATE_DELETE_FAILED_SETTINGS'), 'warning');
         // Return false as the item can't be deleted
         return false;
     }
     // No ISSNs have been used, delete the item
     return parent::delete($pk);
 }
예제 #16
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $nb = $form->getValue('physical_access_controller');
         // Récupère le contrôle d'accès physique sélectionné (grâce à sa position dans le ConfigurationHelper)
         $pac = ConfigurationHelper::getParameter(null, 'physical_access_controller' . ($nb + 1));
         $pac .= $nb + 1;
         $controller = ConfigurationHelper::getParameter($pac, 'controller_name');
         $name = RoomprofilePeer::buildName($controller, $form->getvalue('name'));
         $roomprofile = $form->save();
         $roomprofile->setName($name);
         $roomprofile->save();
         $this->redirect('roomprofile/index?roomId=' . $roomprofile->getRoomId());
     }
     $this->setTemplate('edit');
 }
예제 #17
0
 public function configure()
 {
     // Sort
     $activitySortCriteria = new Criteria();
     $activitySortCriteria->addAscendingOrderByColumn(ActivityPeer::NAME);
     // Layout
     $this->widgetSchema['Activity_id']->setOption('expanded', true);
     $this->widgetSchema['Activity_id']->setOption('criteria', $activitySortCriteria);
     $this->widgetSchema['Zone_id'] = new sfWidgetFormZoneChoice(array('multiple' => false, 'add_empty' => false));
     $this->widgetSchema['unlimitedCredit'] = new sfWidgetFormInputCheckbox();
     $this->widgetSchema['UserGroup_id'] = new sfWidgetFormInputHidden();
     $years = range(date('Y') - 128, date('Y') + 128);
     $this->widgetSchema['start']->setOption('years', array_combine($years, $years));
     $this->widgetSchema['stop']->setOption('years', array_combine($years, $years));
     // Labels
     $activityLabel = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityLabel) || empty($activityLabel)) {
         $activityLabel = 'Activity';
     }
     $this->widgetSchema->setLabel('Activity_id', $activityLabel);
     $this->widgetSchema->setLabel('Zone_id', 'Zone');
     $this->widgetSchema->setLabel('UserGroup_id', 'Group');
     $this->widgetSchema->setLabel('unlimitedCredit', 'Unlimited access');
     $this->widgetSchema->setLabel('minimum_delay', 'Minimum number of hours in advance');
     $this->widgetSchema->setLabel('maximum_delay', 'Maximum number of days in advance');
     $this->widgetSchema->setLabel('minimum_duration', 'Minimum duration of reservations (minutes)');
     $this->widgetSchema->setLabel('maximum_duration', 'Maximum duration of reservations (minutes)');
     $this->widgetSchema->setLabel('hours_per_week', 'How many hours allowed per week (hours)');
     $this->widgetSchema->setLabel('credit', 'Max. credits (hours)');
     // Validators
     $step = sfConfig::get('app_booking_step');
     $this->validatorSchema['credit']->setOption('min', 1);
     $this->validatorSchema['unlimitedCredit'] = new sfValidatorBoolean(array('required' => false));
     $this->validatorSchema['minimum_delay']->setOption('min', 0);
     $this->validatorSchema['maximum_delay']->setOption('min', 0);
     $this->validatorSchema['minimum_duration']->setOption('min', $step);
     $this->validatorSchema['maximum_duration']->setOption('min', $step);
     $this->validatorSchema['hours_per_week']->setOption('min', 1);
     //$this->validatorSchema['hours_per_week']->setOption('max', 170);
     // Defaults
     $this->setDefault('start', strftime("%Y-%m-%d", time()));
     $this->setDefault('stop', strftime("%Y-%m-%d", strtotime('+1 year')));
     $this->setDefault('unlimitedCredit', true);
     // Post validators
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorSchemaCompare('stop', sfValidatorSchemaCompare::GREATER_THAN, 'start', array(), array('invalid' => 'The stop date must be after the start date.')), new sfValidatorSchemaCompare('maximum_duration', sfValidatorSchemaCompare::GREATER_THAN, 'minimum_duration', array(), array('invalid' => 'The maximum duration must be greater than the minimum duration.')))));
 }
 public function configure()
 {
     $this->widgetSchema['print_reserved_by'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_reserved_by'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_reserved_by', 'Display "Reserved by"');
     if (!ConfigurationHelper::hasParameter('Print', 'print_reserved_by')) {
         ConfigurationHelper::setParameter('Print', 'print_reserved_by', true);
     }
     $this->widgetSchema['print_reserved_for'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_reserved_for'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_reserved_for', 'Display "Reserved for"');
     if (!ConfigurationHelper::hasParameter('Print', 'print_reserved_for')) {
         ConfigurationHelper::setParameter('Print', 'print_reserved_for', true);
     }
     $this->widgetSchema['print_reason'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_reason'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_reason', 'Display "Reason"');
     $this->widgetSchema['print_time'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_time'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_time', 'Display "Time"');
     $this->widgetSchema['print_duration'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_duration'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_duration', 'Display "Duration"');
     $this->widgetSchema['print_custom_field1'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_custom_field1'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_custom_field1', 'Display "Custom field 1"');
     $this->widgetSchema['print_custom_field2'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_custom_field2'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_custom_field2', 'Display "Custom field 2"');
     $this->widgetSchema['print_custom_field3'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_custom_field3'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_custom_field3', 'Display "Custom field 3"');
     $this->widgetSchema['print_status'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_status'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_status', 'Display "Status"');
     $this->widgetSchema['print_profile'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_profile'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_profile', 'Display "Physical access"');
     $this->widgetSchema['print_title'] = new sfWidgetFormInputCheckbox();
     $this->validatorSchema['print_title'] = new sfValidatorBoolean(array('required' => false));
     $this->widgetSchema->setLabel('print_title', 'Display titles');
     $this->setDefaults(ConfigurationHelper::getNamespace('Print'));
     $this->widgetSchema->setNameFormat('printConfiguration[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
 }
예제 #19
0
 public static function send($to, $subject, $body, $to_name = null, $from = null, $from_name = null)
 {
     $encryption_method = ConfigurationHelper::getParameter('Email', 'smtp_encryption_method', false);
     $host = ConfigurationHelper::getParameter('Email', 'smtp_host');
     $service = ConfigurationHelper::getParameter('Email', 'smtp_service');
     $use_authentication = ConfigurationHelper::getParameter('Email', 'smtp_use_authentication');
     $username = ConfigurationHelper::getParameter('Email', 'smtp_username');
     $password = ConfigurationHelper::getParameter('Email', 'smtp_password');
     $signature = ConfigurationHelper::getParameter('Email', 'signature');
     if (is_null($from) || ConfigurationHelper::getParameter('Email', 'override_from')) {
         $from = ConfigurationHelper::getParameter('Email', 'from');
     }
     switch ($encryption_method) {
         case 'ssl':
             $encryption = Swift_Connection_SMTP::ENC_SSL;
             break;
         case 'tls':
             $encryption = Swift_Connection_SMTP::ENC_TLS;
             break;
         case 'none':
         default:
             $encryption = Swift_Connection_SMTP::ENC_OFF;
             break;
     }
     $smtp = new Swift_Connection_SMTP($host, $service, $encryption);
     if ($use_authentication) {
         $smtp->setUsername($username);
         $smtp->setPassword($password);
     }
     $message = new Swift_Message($subject, sprintf("%s\n\n%s", $body, $signature));
     $swift = new Swift($smtp);
     if (!is_null($to_name)) {
         $to = new Swift_Address($to, $to_name);
     } else {
         $to = new Swift_Address($to);
     }
     if (!is_null($from_name)) {
         $from = new Swift_Address($from, $from_name);
     } else {
         $from = new Swift_Address($from);
     }
     $swift->send($message, $to, $from);
 }
 public function configure()
 {
     $ipv4_types = array('system' => sfContext::getInstance()->getI18N()->__('System'), 'dhcp' => sfContext::getInstance()->getI18N()->__('DHCP'), 'static' => sfContext::getInstance()->getI18N()->__('Static'));
     $this->widgetSchema['ipv4_type'] = new sfWidgetFormChoice(array('choices' => $ipv4_types));
     $this->validatorSchema['ipv4_type'] = new sfValidatorChoice(array('choices' => array_keys($ipv4_types), 'required' => true));
     $this->widgetSchema->setLabel('ipv4_type', 'IPv4 type');
     $this->widgetSchema['ipv4_address'] = new sfWidgetFormInput();
     $this->validatorSchema['ipv4_address'] = new sfValidatorIPv4Address(array('required' => false));
     $this->widgetSchema->setLabel('ipv4_address', 'IPv4 address');
     $this->widgetSchema['ipv4_netmask'] = new sfWidgetFormInput();
     $this->validatorSchema['ipv4_netmask'] = new sfValidatorIPv4Address(array('required' => false));
     $this->widgetSchema->setLabel('ipv4_netmask', 'IPv4 netmask');
     $this->widgetSchema['ipv4_gateway'] = new sfWidgetFormInput();
     $this->validatorSchema['ipv4_gateway'] = new sfValidatorIPv4Address(array('required' => false));
     $this->widgetSchema->setLabel('ipv4_gateway', 'IPv4 gateway');
     $this->setDefaults(ConfigurationHelper::getNamespace('Network'));
     $this->widgetSchema->setNameFormat('networkConfiguration[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
 }
예제 #21
0
 public function configure()
 {
     $this->setWidgets(array('zone' => new sfWidgetFormZoneChoice(array('current_zone' => null)), 'activities' => new sfWidgetFormPropelChoiceMany(array('model' => 'Activity', 'add_empty' => false, 'expanded' => true)), 'begin_date' => new sfWidgetFormI18nDate(array('culture' => 'fr', 'month_format' => 'number')), 'end_date' => new sfWidgetFormI18nDate(array('culture' => 'fr', 'month_format' => 'number'))));
     $years = range(date('Y') - 128, date('Y'));
     $this->widgetSchema['begin_date']->setOption('years', array_combine($years, $years));
     $this->widgetSchema['end_date']->setOption('years', array_combine($years, $years));
     $this->setDefault('begin_date', date('Y/m/d', strtotime('- 1 month')));
     $this->setDefault('end_date', date('Y/m/d'));
     $this->setValidators(array('zone' => new sfValidatorZoneChoice(array('current_zone' => null, 'required' => false)), 'activities' => new sfValidatorPropelChoiceMany(array('model' => 'Activity', 'column' => 'id', 'required' => false)), 'begin_date' => new sfValidatorDate(array('required' => true)), 'end_date' => new sfValidatorDate(array('required' => true))));
     $activityItem = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityItem) || empty($activityItem)) {
         $activityItem = 'Activities';
     }
     $this->widgetSchema->setLabels(array('zone' => 'Zone', 'activities' => $activityItem, 'begin_date' => 'Start date', 'end_date' => 'Stop date'));
     $this->widgetSchema->setNameFormat('occupancy[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     // Post validators
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('end_date', sfValidatorSchemaCompare::GREATER_THAN_EQUAL, 'begin_date', array(), array('invalid' => 'The stop date must be after the start date.')));
 }
예제 #22
0
 public static function backupFile($file)
 {
     $host = ConfigurationHelper::getParameter('Backup', 'ftp_host');
     $service = ConfigurationHelper::getParameter('Backup', 'ftp_service', 21);
     $username = ConfigurationHelper::getParameter('Backup', 'ftp_username');
     $password = ConfigurationHelper::getParameter('Backup', 'ftp_password');
     $result = false;
     $ch = ftp_connect($host, $service);
     if ($ch) {
         $lr = ftp_login($ch, $username, $password);
         if ($lr) {
             $result = ftp_put($ch, basename($file), $file, FTP_BINARY);
         }
         ftp_close($ch);
     }
     if (!$result) {
         throw new Exception('FTP backup file failed.');
     }
 }
예제 #23
0
 public function configure()
 {
     // Sort
     $sortCriteria = new Criteria();
     $sortCriteria->addAscendingOrderByColumn(ActivityPeer::NAME);
     // Layout
     $this->widgetSchema['activity_has_feature_list']->setOption('expanded', true);
     $this->widgetSchema['activity_has_feature_list']->setOption('criteria', $sortCriteria);
     // Validators
     $this->validatorSchema['name'] = new sfXSSValidatorString(array('max_length' => 128));
     // Labels
     $activityItem = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityItem) || empty($activityItem)) {
         $activityItem = 'Activities';
     }
     $this->widgetSchema->setLabel('activity_has_feature_list', $activityItem);
     // Post-validators
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorPropelUnique(array('model' => 'Feature', 'column' => array('name'))))));
 }
예제 #24
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if (!is_null($form->getValue('home_automation_controller'))) {
             $nb = $form->getValue('home_automation_controller');
             // Récupère le contrôleur domotique sélectionné (grâce à sa position dans le ConfigurationHelper)
             $hac = ConfigurationHelper::getParameter(null, 'home_automation_controller' . ($nb + 1));
             $hac .= $nb + 1;
             $controller = ConfigurationHelper::getParameter($hac, 'controller_name');
             $name = EnergyactionPeer::buildName($controller, $form->getvalue('name'));
             $energyaction = $form->save();
             $energyaction->setName($name);
             $energyaction->save();
         } else {
             $energyaction = $form->save();
         }
         $this->redirect('energyaction/index');
     }
 }
예제 #25
0
 public function configure()
 {
     $i18n = sfContext::getInstance()->getI18N();
     $active_choices = array(null => $i18n->__('Any'), true => $i18n->__('Yes'), false => $i18n->__('No'));
     $activity_name = ConfigurationHelper::getParameter('Rename', 'activity_label');
     $free_field_1_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_1');
     $free_field_2_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_2');
     $free_field_3_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_3');
     if (empty($activity_name)) {
         $activity_name = $i18n->__('Activity');
     }
     $fields_choices = array($i18n->__('Date'), $i18n->__('User'), $activity_name, $i18n->__('Duration'), $i18n->__('Room'), $i18n->__('Reason'), $i18n->__('Comment'), $i18n->__('Group'), $i18n->__('Members count'), $i18n->__('Guests count'), $i18n->__('Status'), $i18n->__('Price'), $i18n->__('Features'));
     if (!empty($free_field_1_name)) {
         $fields_choices[90] = $free_field_1_name;
         // 91
     }
     if (!empty($free_field_2_name)) {
         $fields_choices[91] = $free_field_2_name;
         // 92
     }
     if (!empty($free_field_3_name)) {
         $fields_choices[92] = $free_field_3_name;
         // 93
     }
     $this->setWidgets(array('users' => new sfWidgetFormPropelChoiceMany(array('model' => 'User', 'add_empty' => false, 'expanded' => true)), 'usergroups' => new sfWidgetFormPropelChoiceMany(array('model' => 'Usergroup', 'add_empty' => false, 'expanded' => true)), 'activities' => new sfWidgetFormPropelChoiceMany(array('model' => 'Activity', 'add_empty' => false, 'expanded' => true)), 'zones' => new sfWidgetFormPropelChoiceMany(array('model' => 'Zone', 'add_empty' => false, 'expanded' => true)), 'rooms' => new sfWidgetFormPropelChoiceMany(array('model' => 'Room', 'add_empty' => false, 'expanded' => true)), 'begin_date' => new sfWidgetFormI18nDate(array('culture' => 'fr', 'month_format' => 'number')), 'end_date' => new sfWidgetFormI18nDate(array('culture' => 'fr', 'month_format' => 'number')), 'fields' => new sfWidgetFormChoiceMany(array('choices' => $fields_choices, 'expanded' => true))));
     $begin_years = range(date('Y') - 128, date('Y') + 20);
     $end_years = range(date('Y') - 128, date('Y') + 20);
     $this->widgetSchema['begin_date']->setOption('years', array_combine($begin_years, $begin_years));
     $this->widgetSchema['end_date']->setOption('years', array_combine($end_years, $end_years));
     $this->setDefault('begin_date', date('Y/m/d', strtotime('- 1 month')));
     $this->setDefault('end_date', date('Y/m/d'));
     // Select default selected filters
     $this->setDefault('fields', array(0, 1, 2, 3, 4, 7));
     // array_keys($fields_choices));
     $this->setValidators(array('users' => new sfValidatorPropelChoiceMany(array('model' => 'User', 'column' => 'id', 'required' => false)), 'usergroups' => new sfValidatorPropelChoiceMany(array('model' => 'Usergroup', 'column' => 'id', 'required' => false)), 'activities' => new sfValidatorPropelChoiceMany(array('model' => 'Activity', 'column' => 'id', 'required' => false)), 'zones' => new sfValidatorPropelChoiceMany(array('model' => 'Zone', 'column' => 'id', 'required' => false)), 'rooms' => new sfValidatorPropelChoiceMany(array('model' => 'Room', 'column' => 'id', 'required' => false)), 'begin_date' => new sfValidatorDate(array('required' => true)), 'end_date' => new sfValidatorDate(array('required' => true)), 'fields' => new sfValidatorChoiceMany(array('choices' => array_keys($fields_choices), 'required' => true))));
     $this->widgetSchema->setLabels(array('users' => 'Users', 'usergroups' => 'Groups', 'activities' => $activity_name, 'zones' => 'Zones', 'rooms' => 'Rooms', 'begin_date' => 'Start date', 'end_date' => 'Stop date', 'fields' => 'Fields'));
     $this->widgetSchema->setNameFormat('reporting[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     // Post validators
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('end_date', sfValidatorSchemaCompare::GREATER_THAN_EQUAL, 'begin_date', array(), array('invalid' => 'The stop date must be after the start date.')));
 }
예제 #26
0
 public function executePrepareLogin(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post'));
     if (!$this->getUser()->isAuthenticated()) {
         $username = $request->getParameter('username');
         $password = $request->getParameter('password');
         $user = null;
         if (ConfigurationHelper::getParameter('General', 'auth_ldap_choice', false)) {
             // Need to authenticate with LDAP server
             $server = ConfigurationHelper::getParameter('General', 'auth_ldap_host', '');
             $domain = ConfigurationHelper::getParameter('General', 'auth_ldap_domain', '');
             $ldap = @ldap_connect($server);
             // ex: myldapserver.company.com
             if ($ldap) {
                 ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
                 ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
                 // Process the username for good domain name
                 $ldpa_username = $username . '@' . $domain;
                 // ex: Administrator@MYDOMAIN.com
                 $bind = @ldap_bind($ldap, $ldpa_username, $password);
                 if ($bind) {
                     $user = UserPeer::retrieveByLogin($username);
                 }
                 ldap_close($ldap);
             }
         } else {
             $user = UserPeer::authenticate($username, $password);
         }
         if (!empty($user) && $user->getIsActive()) {
             $this->getUser()->setTemposUser($user);
             $referer = $request->getParameter('referer');
             if (empty($referer)) {
                 $referer = 'home/index';
             }
             $this->redirect($referer);
         } else {
             $this->getUser()->setFlash('loginError', true);
         }
     }
     $this->redirect('login/login');
 }
 public function configure()
 {
     $this->widgetSchema['activity_module'] = new sfWidgetFormInput();
     $this->validatorSchema['activity_module'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('activity_module', 'Activities module');
     $this->widgetSchema['activity_label'] = new sfWidgetFormInput();
     $this->validatorSchema['activity_label'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('activity_label', 'Activities item');
     $this->widgetSchema['reservation_custom_field_1'] = new sfWidgetFormInput();
     $this->validatorSchema['reservation_custom_field_1'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('reservation_custom_field_1', 'Free field 1');
     $this->widgetSchema['reservation_custom_field_2'] = new sfWidgetFormInput();
     $this->validatorSchema['reservation_custom_field_2'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('reservation_custom_field_2', 'Free field 2');
     $this->widgetSchema['reservation_custom_field_3'] = new sfWidgetFormInput();
     $this->validatorSchema['reservation_custom_field_3'] = new sfValidatorString(array('required' => false));
     $this->widgetSchema->setLabel('reservation_custom_field_3', 'Free field 3');
     $this->setDefaults(ConfigurationHelper::getNamespace('Rename'));
     $this->widgetSchema->setNameFormat('renameConfiguration[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
 }
예제 #28
0
 public function configure()
 {
     $c = new Criteria();
     // Choices
     $active_choices = array(null => sfContext::getInstance()->getI18N()->__('Any'), true => sfContext::getInstance()->getI18N()->__('Yes'), false => sfContext::getInstance()->getI18N()->__('No'));
     $this->setWidgets(array('login' => new sfWidgetFormInput(), 'family_name' => new sfWidgetFormInput(), 'surname' => new sfWidgetFormInput(), 'usergroupsAsLeader' => new sfWidgetFormPropelChoiceMany(array('model' => 'Usergroup', 'add_empty' => false, 'expanded' => true, 'criteria' => $c)), 'usergroupsAsMember' => new sfWidgetFormPropelChoiceMany(array('model' => 'Usergroup', 'add_empty' => false, 'expanded' => true, 'criteria' => $c)), 'activities' => new sfWidgetFormPropelChoiceMany(array('model' => 'Activity', 'add_empty' => false, 'expanded' => true)), 'is_active' => new sfWidgetFormChoice(array('choices' => $active_choices)), 'card_number' => new sfWidgetFormInput(), 'begin_date' => new sfWidgetFormI18nDate(array('culture' => 'fr', 'month_format' => 'number')), 'end_date' => new sfWidgetFormI18nDate(array('culture' => 'fr', 'month_format' => 'number')), 'email_address' => new sfWidgetFormInput(), 'address' => new sfWidgetFormInput(), 'phone_number' => new sfWidgetFormInput()));
     $years = range(date('Y') - 128, date('Y'));
     $this->widgetSchema['begin_date']->setOption('years', array_combine($years, $years));
     $this->widgetSchema['end_date']->setOption('years', array_combine($years, $years));
     $minimum_birth_date = '01/01/1910';
     $this->setDefault('is_active', null);
     $this->setDefault('begin_date', $minimum_birth_date);
     $this->setDefault('end_date', date('m/d/Y'));
     $this->setValidators(array('login' => new sfValidatorString(array('max_length' => 64, 'required' => false)), 'family_name' => new sfValidatorString(array('max_length' => 64, 'required' => false)), 'surname' => new sfValidatorString(array('max_length' => 64, 'required' => false)), 'usergroupsAsLeader' => new sfValidatorPropelChoiceMany(array('model' => 'Usergroup', 'column' => 'id', 'required' => false)), 'usergroupsAsMember' => new sfValidatorPropelChoiceMany(array('model' => 'Usergroup', 'column' => 'id', 'required' => false)), 'activities' => new sfValidatorPropelChoiceMany(array('model' => 'Activity', 'column' => 'id', 'required' => false)), 'is_active' => new sfValidatorChoice(array('choices' => array_keys($active_choices), 'required' => false)), 'card_number' => new sfValidatorString(array('max_length' => 32, 'required' => false)), 'begin_date' => new sfValidatorDate(array('required' => false)), 'end_date' => new sfValidatorDate(array('required' => false)), 'email_address' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'address' => new sfValidatorString(array('max_length' => 256, 'required' => false)), 'phone_number' => new sfValidatorString(array('max_length' => 64, 'required' => false))));
     $activityItem = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityItem) || empty($activityItem)) {
         $activityItem = 'Activities';
     }
     $this->widgetSchema->setLabels(array('login' => 'Username', 'family_name' => 'Family name', 'surname' => 'Surname', 'usergroupsAsLeader' => 'Groups as leader', 'usergroupsAsMember' => 'Groups as member', 'activities' => $activityItem, 'is_active' => 'Is active', 'card_number' => 'Card number', 'begin_date' => 'Minimum birth date', 'end_date' => 'Maximum birth date', 'email_address' => 'Email address', 'address' => 'Address', 'phone_number' => 'Phone number'));
     $this->widgetSchema->setNameFormat('userSearch[%s]');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     // Post validators
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('end_date', sfValidatorSchemaCompare::GREATER_THAN_EQUAL, 'begin_date', array(), array('invalid' => 'The stop date must be after the start date.')));
 }
 /**
  * Get the configuration.
  *
  * \return The configuration array.
  */
 public function getConfiguration()
 {
     $configuration = ConfigurationHelper::getNamespace($this->getName());
     return array_merge($this->defaultValues, $configuration);
 }
예제 #30
0
	<?php 
echo $authenticated ? __('logout') : __('login');
?>
</a>
<?php 
if (!$authenticated) {
    ?>
	- <a href="<?php 
    echo url_for('login/cardLogin');
    ?>
"><?php 
    echo __('login with a card');
    ?>
</a>
	<?php 
    if (ConfigurationHelper::getParameter('General', 'allow_registration', true)) {
        ?>
		- <a href="<?php 
        echo url_for('login/register');
        ?>
"><?php 
        echo __('register');
        ?>
</a>
	<?php 
    }
} else {
    ?>
	<?php 
    if ($is_admin) {
        ?>