/** * 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($tableName = '', $idField = '', $passwordField = '', $methodField = '') { $passwords = $this->db->fetchPairs("SELECT {$idField}, {$passwordField} FROM {$tableName} WHERE {$passwordField} IS NOT NULL AND {$methodField} IS NULL"); if ($passwords) { $values[$methodField] = 'default'; foreach ($passwords as $key => $password) { $values[$passwordField] = $this->project->encrypt($password, $values[$methodField]); $this->db->update($tableName, $values, "{$idField} = '{$key}'"); } $this->getBatch()->addMessage(sprintf($this->_('%d passwords encrypted for table %s.'), count($passwords), $tableName)); } else { $this->getBatch()->addMessage(sprintf($this->_('No passwords found in table %s.'), $tableName)); } }
/** * A ModelAbstract->setOnSave() function that returns the input * date as a valid date. * * @see \MUtil_Model_ModelAbstract * * @param mixed $value The value being saved * @param boolean $isNew True when a new item is being saved * @param string $name The name of the current field * @param array $context Optional, the other values being saved * @return \Zend_Date */ public function saveValue($value, $isNew = false, $name = null, array $context = array()) { if ($value) { // \MUtil_Echo::track($value); return $this->project->encrypt($value, 'default'); } }