public function initFields($extra = array()) { $this->user = $extra['user']; $this->project = $extra['project']; if ($this->user->hasPerm('IDF.project-owner', $this->project) or $this->user->hasPerm('IDF.project-member', $this->project)) { $this->show_full = true; } $this->fields['summary'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Summary'), 'initial' => '', 'widget_attrs' => array('maxlength' => 200, 'size' => 67))); $this->fields['description'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Description'), 'initial' => '', 'widget' => 'Pluf_Form_Widget_TextareaInput', 'widget_attrs' => array('cols' => 58, 'rows' => 7))); $sql = new Pluf_SQL('project=%s', array($this->project->id)); $commits = Pluf::factory('IDF_Commit')->getList(array('order' => 'creation_dtime DESC', 'nb' => 10, 'filter' => $sql->gen())); $choices = array(); foreach ($commits as $c) { $id = strlen($c->scm_id) > 10 ? substr($c->scm_id, 0, 10) : $c->scm_id; $ext = mb_strlen($c->summary) > 50 ? mb_substr($c->summary, 0, 47) . '...' : $c->summary; $choices[$id . ' - ' . $ext] = $c->scm_id; } $this->fields['commit'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Commit'), 'initial' => '', 'widget' => 'Pluf_Form_Widget_SelectInput', 'widget_attrs' => array('choices' => $choices))); $upload_path = Pluf::f('upload_issue_path', false); if (false === $upload_path) { throw new Pluf_Exception_SettingError(__('The "upload_issue_path" configuration variable was not set.')); } $md5 = md5(rand() . microtime() . Pluf_Utils::getRandomString()); // We add .dummy to try to mitigate security issues in the // case of someone allowing the upload path to be accessible // to everybody. $filename = substr($md5, 0, 2) . '/' . substr($md5, 2, 2) . '/' . substr($md5, 4) . '/%s.dummy'; $this->fields['patch'] = new Pluf_Form_Field_File(array('required' => true, 'label' => __('Patch'), 'move_function_params' => array('upload_path' => $upload_path, 'upload_path_create' => true, 'file_name' => $filename))); if ($this->show_full) { $this->fields['status'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Status'), 'initial' => 'New', 'widget_attrs' => array('maxlength' => 20, 'size' => 15))); } }
public function initFields($extra = array()) { $this->user = $extra['user']; $this->project = $extra['project']; $this->issue = $extra['issue']; if ($this->user->hasPerm('IDF.project-owner', $this->project) or $this->user->hasPerm('IDF.project-member', $this->project)) { $this->show_full = true; } if ($this->show_full) { $this->fields['summary'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Summary'), 'initial' => $this->issue->summary, 'widget_attrs' => array('maxlength' => 200, 'size' => 67))); } $this->fields['content'] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Comment'), 'initial' => '', 'widget' => 'Pluf_Form_Widget_TextareaInput', 'widget_attrs' => array('cols' => 58, 'rows' => 9))); $upload_path = Pluf::f('upload_issue_path', false); if (false === $upload_path) { throw new Pluf_Exception_SettingError(__('The "upload_issue_path" configuration variable was not set.')); } $md5 = md5(rand() . microtime() . Pluf_Utils::getRandomString()); // We add .dummy to try to mitigate security issues in the // case of someone allowing the upload path to be accessible // to everybody. for ($i = 1; $i < 4; $i++) { $filename = substr($md5, 0, 2) . '/' . substr($md5, 2, 2) . '/' . substr($md5, 4) . '/%s.dummy'; $this->fields['attachment' . $i] = new Pluf_Form_Field_File(array('required' => false, 'label' => __('Attach a file'), 'move_function_params' => array('upload_path' => $upload_path, 'upload_path_create' => true, 'file_name' => $filename))); } if ($this->show_full) { $this->fields['status'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Status'), 'initial' => $this->issue->get_status()->name, 'widget_attrs' => array('maxlength' => 20, 'size' => 15))); $initial = $this->issue->get_owner() == null ? '' : $this->issue->get_owner()->login; $this->fields['owner'] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Owner'), 'initial' => $initial, 'widget_attrs' => array('maxlength' => 20, 'size' => 15))); $tags = $this->issue->get_tags_list(); for ($i = 1; $i < 7; $i++) { $initial = ''; if (isset($tags[$i - 1])) { if ($tags[$i - 1]->class != 'Other') { $initial = (string) $tags[$i - 1]; } else { $initial = $tags[$i - 1]->name; } } $this->fields['label' . $i] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Labels'), 'initial' => $initial, 'widget_attrs' => array('maxlength' => 50, 'size' => 20))); } } }
public function initFields($extra = array()) { $this->user = $extra['user']; $this->project = $extra['project']; if ($this->user->hasPerm('IDF.project-owner', $this->project) or $this->user->hasPerm('IDF.project-member', $this->project)) { $this->show_full = true; } $this->fields['summary'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Summary'), 'initial' => '', 'widget_attrs' => array('maxlength' => 200, 'size' => 67))); $this->fields['content'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Description'), 'initial' => '', 'widget' => 'Pluf_Form_Widget_TextareaInput', 'widget_attrs' => array('cols' => 58, 'rows' => 13))); $upload_path = Pluf::f('upload_issue_path', false); if (false === $upload_path) { throw new Pluf_Exception_SettingError(__('The "upload_issue_path" configuration variable was not set.')); } $md5 = md5(rand() . microtime() . Pluf_Utils::getRandomString()); // We add .dummy to try to mitigate security issues in the // case of someone allowing the upload path to be accessible // to everybody. for ($i = 1; $i < 4; $i++) { $filename = substr($md5, 0, 2) . '/' . substr($md5, 2, 2) . '/' . substr($md5, 4) . '/%s.dummy'; $this->fields['attachment' . $i] = new Pluf_Form_Field_File(array('required' => false, 'label' => __('Attach a file'), 'move_function_params' => array('upload_path' => $upload_path, 'upload_path_create' => true, 'file_name' => $filename))); } if ($this->show_full) { $this->fields['status'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Status'), 'initial' => 'New', 'widget_attrs' => array('maxlength' => 20, 'size' => 15))); $this->fields['owner'] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Owner'), 'initial' => '', 'widget_attrs' => array('maxlength' => 20, 'size' => 15))); for ($i = 1; $i < 7; $i++) { $initial = ''; switch ($i) { case 1: $initial = 'Type:Defect'; break; case 2: $initial = 'Priority:Medium'; break; } $this->fields['label' . $i] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Labels'), 'initial' => $initial, 'widget_attrs' => array('maxlength' => 50, 'size' => 20))); } } }
/** * Set the password of a user. * * You need to manually save the user to store the password in the * database. The supported algorithms are md5, crc32 and sha1, * sha1 being the default. * * @param string New password * @return bool Success */ function setPassword($password) { $salt = Pluf_Utils::getRandomString(5); $this->password = '******' . $salt . ':' . sha1($salt . $password); return true; }
function Pluf_DB_PasswordToDb($val, $db) { $exp = explode(':', $val); if (in_array($exp[0], array('sha1', 'md5', 'crc32'))) { return $db->esc($val); } // We need to hash the value. $salt = Pluf_Utils::getRandomString(5); return $db->esc('sha1:' . $salt . ':' . sha1($salt . $val)); }
public function initFields($extra = array()) { $this->user = $extra['user']; $this->project = $extra['project']; if ($this->user->hasPerm('IDF.project-owner', $this->project) or $this->user->hasPerm('IDF.project-member', $this->project)) { $this->show_full = true; } $contentTemplate = $this->project->getConf()->getVal('labels_issue_template', IDF_Form_IssueTrackingConf::init_template); $this->fields['summary'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Summary'), 'initial' => '', 'widget_attrs' => array('maxlength' => 200, 'size' => 67))); $this->fields['content'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Description'), 'initial' => $contentTemplate, 'widget' => 'Pluf_Form_Widget_TextareaInput', 'widget_attrs' => array('cols' => 58, 'rows' => 13))); $upload_path = Pluf::f('upload_issue_path', false); if (false === $upload_path) { throw new Pluf_Exception_SettingError(__('The "upload_issue_path" configuration variable was not set.')); } $md5 = md5(rand() . microtime() . Pluf_Utils::getRandomString()); // We add .dummy to try to mitigate security issues in the // case of someone allowing the upload path to be accessible // to everybody. for ($i = 1; $i < 4; $i++) { $filename = substr($md5, 0, 2) . '/' . substr($md5, 2, 2) . '/' . substr($md5, 4) . '/%s.dummy'; $this->fields['attachment' . $i] = new Pluf_Form_Field_File(array('required' => false, 'label' => __('Attach a file'), 'move_function_params' => array('upload_path' => $upload_path, 'upload_path_create' => true, 'file_name' => $filename))); } if ($this->show_full) { $this->fields['status'] = new Pluf_Form_Field_Varchar(array('required' => true, 'label' => __('Status'), 'initial' => 'New', 'widget_attrs' => array('maxlength' => 20, 'size' => 15))); $this->fields['owner'] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Owner'), 'initial' => '', 'widget_attrs' => array('maxlength' => 20, 'size' => 15))); /* * get predefined tags for issues from current project * * first Type:<...> and Priority:<...> will be used * */ $predefined = preg_split("/[\r\n]+/", $extra['project']->getConf()->getVal('labels_issue_predefined')); $predefined_type = 'Type:Defect'; foreach ($predefined as $tag) { if (strpos($tag, 'Type:') === 0) { $predefined_type = explode('=', $tag, 2); $predefined_type = trim($predefined_type[0]); break; } } $predefined_priority = 'Priority:Medium'; foreach ($predefined as $tag) { if (strpos($tag, 'Priority:') === 0) { $predefined_priority = explode('=', $tag, 2); $predefined_priority = trim($predefined_priority[0]); break; } } for ($i = 1; $i < 7; $i++) { $initial = ''; switch ($i) { case 1: $initial = $predefined_type; break; case 2: $initial = $predefined_priority; break; } $this->fields['label' . $i] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Labels'), 'initial' => $initial, 'widget_attrs' => array('maxlength' => 50, 'size' => 20))); } } }