'pm_admin' => array(0, 1),
'forum_admin' => array(0, 1),
- 'tracker' => array(0, 1, 3, 5, 7),
+ 'tracker' => array(0, 1, 9, 11, 13, 15),
'pm' => array(0, 1, 3, 5, 7),
'forum' => array(0, 1, 2, 3, 4),
- 'new_tracker' => array(0, 1, 3, 5, 7),
+ 'new_tracker' => array(0, 1, 9, 11, 13, 15),
'new_pm' => array(0, 1, 3, 5, 7),
'new_forum' => array(0, 1, 2, 3, 4),
'forum_admin' => 1,
'new_forum' => 3,
'tracker_admin' => 1,
- 'new_tracker' => 7,
+ 'new_tracker' => 15,
'pm_admin' => 1,
'new_pm' => 7,
'webcal' => 2,
'forum_admin' => 1,
'new_forum' => 3,
'tracker_admin' => 1,
- 'new_tracker' => 7,
+ 'new_tracker' => 15,
'pm_admin' => 1,
'new_pm' => 7,
'webcal' => 2,
'scm' => 2,
'docman' => 2,
'new_forum' => 3,
- 'new_tracker' => 3,
+ 'new_tracker' => 11,
'new_pm' => 3,
'webcal' => 2,
),
'frs' => 2,
'docman' => 4,
'new_forum' => 3,
- 'new_tracker' => 1,
+ 'new_tracker' => 9,
'new_pm' => 1,
'webcal' => 2,
),
'docman' => 1,
'new_forum' => 3,
'tracker_admin' => 1,
- 'new_tracker' => 3,
+ 'new_tracker' => 11,
'pm_admin' => 1,
'new_pm' => 7,
'webcal' => 2,
//
// Build an associative array of these key values + localized description
//
- $role_vals[$section][$this->role_values[$section][$i]]=$rbac_permission_names["$section".$this->role_values[$section][$i]];
+ $role_vals[$section][$this->role_values[$section][$i]] =
+ util_ifsetor($rbac_permission_names["$section".$this->role_values[$section][$i]],
+ _('UNKNOWN (internal error, report bug to FusionForge)'));
}
}
return $role_vals[$section];
case 'manager':
return (($value & 4) != 0) ;
break ;
+ case 'submit':
+ return (($value & 8) != 0) ;
+ break ;
+ /*
+ * bit4 (value & 16) is reserved
+ * for tracker item vote from Evolvis
+ */
}
break ;
}
public function addUser ($user) {
- return $this->addUsers (array ($user)) ;
+ if (!$this->addUsers (array ($user))) {
+ return false;
+ }
+ $hook_params['user'] = $user;
+ $hook_params['role'] = $this;
+ plugin_hook ("role_adduser", $hook_params);
+
+ return true;
}
public function removeUsers($users) {
}
public function removeUser ($user) {
- return $this->removeUsers (array ($user)) ;
+ if(!$this->removeUsers (array ($user))){
+ return false;
+ }
+ $hook_params['user'] = $user;
+ $hook_params['role'] = $this;
+ plugin_hook ("role_removeuser", $hook_params);
+
+ return true;
}
public function getUsers() {
if(empty($data)) {
return $data;
}
- $lines = explode("\n", $data);
+ $withPattern = 0;
+ for ($i = 0; $i < 5; $i++) {
+ $randPattern = rand(10000, 30000);
+ if (! preg_match("/$randPattern/", $data)) {
+ $withPattern = 1;
+ break;
+ }
+ }
+ if ($withPattern) {
+/*
+ while(preg_match('/<a [^>]*>[^<]*<\/a>/i', $data, $part)) {
+ $mem[] = $part[0];
+ $data = preg_replace('/<a [^>]*>[^<]*<\/a>/i', $randPattern, $data, 1);
+ }
+*/
+ $mem = array();
+ while(preg_match('/<a [^>]*>.*<\/a>/siU', $data, $part)) {
+ $mem[] = $part[0];
+ $data = preg_replace('/<a [^>]*>.*<\/a>/siU', $randPattern, $data, 1);
+ }
+ while(preg_match('/<img [^>]*\/>/siU', $data, $part)) {
+ $mem[] = $part[0];
+ $data = preg_replace('/<img [^>]*\/>/siU', $randPattern, $data, 1);
+ }
+ $data = str_replace('>', "\1", $data);
+ $data = preg_replace("#([ \t]|^)www\.#i"," http://www.",$data);
+ $data = preg_replace("#([[:alnum:]]+)://([^[:space:]<\1]*)([[:alnum:]\#?/&=])#i", "<a href=\"\\1://\\2\\3\" target=\"_new\">\\1://\\2\\3</a>", $data);
+ $data = preg_replace("#([[:space:]]|^)(([a-z0-9_]|\\-|\\.)+@([^[:space:]<\1]*)([[:alnum:]-]))#i", "\\1<a href=\"mailto:\\2\" target=\"_new\">\\2</a>", $data);
+ $data = str_replace("\1", '>', $data);
+ for ($i = 0; $i < count($mem); $i++) {
+ $data = preg_replace("/$randPattern/", $mem[$i], $data, 1);
+ }
+ return($data);
+ }
+
+ $lines = split("\n",$data);
$newText = "";
while ( list ($key, $line) = each ($lines)) {
+ // Do not scan lines if they already have hyperlinks.
+ // Avoid problem with text written with an WYSIWYG HTML editor.
+ if (eregi('<a ([^>]*)>.*</a>', $line, $linePart)) {
+ if (eregi('href="[^"]*"', $linePart[1])) {
+ $newText .= $line;
+ continue;
+ }
+ }
+
+ // Skip </img> tag also
+ if (eregi('<img ([^>]*)/>', $line, $linePart)) {
+ if (eregi('href="[^"]*"', $linePart[1])) {
+ $newText .= $line;
+ continue;
+ }
+ }
+
// When we come here, we usually have form input
// encoded in entities. Our aim is to NOT include
// angle brackets in the URL
/**
* Return URL prefix (http:// or https://)
*
+ * @param string $prefix (optional) : 'http' or 'https' to force it
* @return string URL prefix
*/
-function util_url_prefix() {
- if (forge_get_config('use_ssl')) {
- return "https://";
- } else {
- return "http://";
+function util_url_prefix($prefix = '') {
+ if ($prefix == 'http' || $prefix == 'https' ) {
+ return $prefix . '://';
+ }
+ else {
+ if (forge_get_config('use_ssl')) {
+ return "https://";
+ } else {
+ return "http://";
+ }
}
}
/**
* Construct the base URL http[s]://forge_name[:port]
*
+ * @param string $prefix (optional) : 'http' or 'https' to force it
* @return string base URL
*/
-function util_make_base_url() {
- $url = util_url_prefix();
+function util_make_base_url($prefix = '') {
+ $url = util_url_prefix($prefix);
$url .= forge_get_config('web_host') ;
if (forge_get_config('https_port') && (forge_get_config('https_port') != 443)) {
$url .= ":".forge_get_config('https_port') ;
/**
* Construct full URL from a relative path
*
- * @param string $path
+ * @param string $path (optional)
+ * @param string $prefix (optional) : 'http' or 'https' to force it
* @return string URL
*/
-function util_make_url($path = '') {
- $url = util_make_base_url().util_make_uri($path) ;
+function util_make_url($path = '', $prefix = '') {
+ $url = util_make_base_url($prefix).util_make_uri($path) ;
return $url;
}
return ($ashtml ? util_html_encode($rv) : $rv);
}
+ /**
+ * util_sanitise_multiline_submission() – Convert text to ASCII CR-LF
+ *
+ * @param string $text
+ * input string to sanitise
+ * @return string
+ * sanitised string: CR, LF or CR-LF converted to CR-LF
+ */
+ function util_sanitise_multiline_submission($text) {
+ /* convert all CR-LF into LF */
+ $text = preg_replace("/\015+\012+/m", "\012", $text);
+ /* convert all CR or LF into CR-LF */
+ $text = preg_replace("/[\012\015]/m", "\015\012", $text);
+
+ return $text;
+ }
+
+
// Local Variables:
// mode: php
// c-file-style: "bsd"
create_db_admin_user(){
gforge_db="$1"
admin_user="$2"
- su - postgres -c "psql $gforge_db -c \"INSERT INTO users (user_name, realname, firstname, lastname, email, user_pw, unix_pw, status, theme_id) VALUES ('$admin_user', 'Forge Admin', 'Forge', 'Admin', 'root@localhost.localdomain', 'INVALID', 'INVALID', 'A', 1); INSERT INTO user_group (user_id, group_id, admin_flags, role_id) VALUES (currval('users_pk_seq'), 1, 'A',17); INSERT INTO pfo_user_role (user_id, role_id) VALUES (currval('users_pk_seq'), 3)\""
+ su - postgres -c "psql $gforge_db -c \"INSERT INTO users (user_name, realname, firstname, lastname, email, user_pw, unix_pw, status, theme_id) VALUES ('$admin_user', 'Forge Admin', 'Forge', 'Admin', 'root@localhost.localdomain', 'INVALID', 'INVALID', 'A', 1); INSERT INTO pfo_user_role (user_id, role_id) VALUES (currval('users_pk_seq'), 3)\""
}
find_psql_init(){
esac
msg green " * Loading FusionForge DB"
- su $susufix $gforge_user -c "psql $gforge_db < $fusionforge_src_dir/db/gforge.sql" >> /tmp/gforge-import.log
+ su $susufix $gforge_user -c "psql $gforge_db < $fusionforge_src_dir/db/gforge.sql" >> /tmp/gforge-import.log 2>&1
msg green " * Running php db/upgrade-db.php"
- php $fusionforge_src_dir/db/upgrade-db.php >> /tmp/gforge-upgrade.log 2>&1
-
+ if ! php $fusionforge_src_dir/db/upgrade-db.php >> /tmp/gforge-upgrade.log ; then
+ msg red "upgrade-db.php failed."
+ return 1
+ fi
-
if [ -z "$FFORGE_ADMIN_USER" ]
then
while test -z "$FFORGE_ADMIN_USER"