diff --git a/codepot/etc/codepot.ini.in b/codepot/etc/codepot.ini.in index ed84904c..9b36bac3 100644 --- a/codepot/etc/codepot.ini.in +++ b/codepot/etc/codepot.ini.in @@ -29,6 +29,9 @@ ldap_server_port = "389" ldap_server_protocol_version = "3" ldap_userid_format = "${userid}" ldap_password_format = "${password}" +ldap_mail_attribute_name = "" +ldap_admin_binddn = "" +ldap_admin_password = "" ;------------------------------------------------------------------------------ ; default langage to use. set it to 'auto' to detect it automatically. diff --git a/codepot/src/codepot/controllers/api.php b/codepot/src/codepot/controllers/api.php index 0fa41cd5..bd500bdf 100644 --- a/codepot/src/codepot/controllers/api.php +++ b/codepot/src/codepot/controllers/api.php @@ -20,7 +20,6 @@ class API extends Controller if (!isset($projectid) || !isset($userid)) return 'NO'; - // TODO: access control - may allow localhost only $this->load->model ('ProjectModel', 'projects'); print ($this->projects->projectHasMember ($projectid, $userid) === FALSE)? 'NO': 'YES'; } @@ -31,7 +30,6 @@ class API extends Controller if (!isset($projectid) || !isset($userid)) return 'NO'; - // TODO: access control - may allow localhost only $this->load->model ('ProjectModel', 'projects'); print ($this->projects->projectIsOwnedBy ($projectid, $userid) === FALSE)? 'NO': 'YES'; } @@ -42,9 +40,18 @@ class API extends Controller if (!isset($repo) || !isset($rev)) return; - // TODO: access control - may allow localhost only $this->load->model ('LogModel', 'logs'); $this->logs->writeCodeCommit ($type, $repo, $rev, ''); + + + /* + $this->load->library ('email'); + $this->email->from ('xxxx'); + $this->email->to ('xxxx'); + $this->email->subject ('xxxx'); + $this->email->message ('xxxx'); + $this->email->send (); + */ } } diff --git a/codepot/src/codepot/controllers/file.php b/codepot/src/codepot/controllers/file.php index 886d697e..c2c0cf51 100644 --- a/codepot/src/codepot/controllers/file.php +++ b/codepot/src/codepot/controllers/file.php @@ -153,6 +153,24 @@ class File extends Controller } else { + $path = CODEPOT_FILE_DIR . '/' . $file->encname; + $mtime = @filemtime ($path); + if ($mtime === FALSE) $mtime = time(); + header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT"); + //header("Expires: 0"); + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename={$name}"); + header("Content-Transfer-Encoding: binary"); + flush (); + $x = @readfile($path); + if ($x === FALSE) + { + $data['project'] = $project; + $data['message'] = "CANNOT GET FILE - {$file->name}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + + /* $this->load->helper('download'); $path = CODEPOT_FILE_DIR . '/' . $file->encname; $data = @file_get_contents ($path); @@ -166,6 +184,7 @@ class File extends Controller { force_download ($name, $data); } + */ } } } diff --git a/codepot/src/codepot/models/ldaploginmodel.php b/codepot/src/codepot/models/ldaploginmodel.php index 76c89884..994f0d69 100644 --- a/codepot/src/codepot/models/ldaploginmodel.php +++ b/codepot/src/codepot/models/ldaploginmodel.php @@ -34,10 +34,78 @@ class LdapLoginModel extends LoginModel return FALSE; } + $email = ''; + if (CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME != '') + { + $filter = '(' . CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME . '=*)'; + $r = @ldap_search ($ldap, $f_userid, $filter, array(CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME)); + if ($r !== FALSE) + { + $e = @ldap_get_entries($ldap, $r); + if ($e !== FALSE && count($e) > 0 && + array_key_exists(CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME, $e[0])) + { + $email = $e[0][CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME][0]; + } + } + } + + @ldap_unbind ($bind); @ldap_close ($ldap); - return parent::authenticate ($userid, $password); + return parent::authenticate ($userid, $password, $email); + } + + function queryUserInfo ($userid) + { + $ldap = @ldap_connect ( + CODEPOT_LDAP_SERVER_HOST, CODEPOT_LDAP_SERVER_PORT); + if ($ldap === FALSE) + { + $this->setErrorMessage ("Can't connect to LDAP server"); + return FALSE; + } + + if (CODEPOT_LDAP_SERVER_PROTOCOL_VERSION !== FALSE) + { + ldap_set_option ($ldap, LDAP_OPT_PROTOCOL_VERSION, CODEPOT_LDAP_SERVER_PROTOCOL_VERSION); + } + + $bind = @ldap_bind ($ldap, CODEPOT_LDAP_ADMIN_BINDDN, CODEPOT_LDAP_ADMIN_PASSWORD); + if ($bind === FALSE) + { + $this->setErrorMessage (ldap_error ($ldap)); + ldap_close ($ldap); + return FALSE; + } + + $f_userid = $this->formatString (CODEPOT_LDAP_USERID_FORMAT, $userid, ''); + $email = ''; + + if (CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME != '') + { + $filter = '(' . CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME . '=*)'; + $r = @ldap_search ($ldap, $f_userid, $filter, array(CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME)); + if ($r !== FALSE) + { + $e = @ldap_get_entries($ldap, $r); + if ($e !== FALSE && count($e) > 0 && + array_key_exists(CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME, $e[0])) + { + $email = $e[0][CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME][0]; + } + } + } + + + @ldap_unbind ($bind); + @ldap_close ($ldap); + + $user['id'] = $userid; + $user['email'] = $email; + + return $user; } } diff --git a/codepot/src/codepot/models/loginmodel.php b/codepot/src/codepot/models/loginmodel.php index 516400b9..e8847594 100644 --- a/codepot/src/codepot/models/loginmodel.php +++ b/codepot/src/codepot/models/loginmodel.php @@ -22,6 +22,7 @@ class LoginModel extends Model if ($server1 != $server2) { $userid = ''; + $email = ''; $issysadmin = FALSE; } else @@ -29,17 +30,21 @@ class LoginModel extends Model $userid = $this->session->userdata('userid'); if ($userid === NULL) $userid = ''; + $email = $this->session->userdata('email'); + if ($email === NULL) $email = ''; + $issysadmin = $this->session->userdata('sysadmin?'); if ($issysadmin === NULL) $issysadmin = FALSE; } return array ( 'id' => $userid, + 'email' => $email, 'sysadmin?' => $issysadmin ); } - function authenticate ($userid, $password) + function authenticate ($userid, $password, $email = '') { $server = $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT']; @@ -58,9 +63,11 @@ class LoginModel extends Model array ( 'userid' => $userid, 'server' => $server, + 'email' => $email, 'sysadmin?' => $sysadmin ) ); + return TRUE; } diff --git a/codepot/src/codepot/views/log.php b/codepot/src/codepot/views/log.php index ab997086..b7c727a4 100644 --- a/codepot/src/codepot/views/log.php +++ b/codepot/src/codepot/views/log.php @@ -3,7 +3,7 @@ - + diff --git a/codepot/src/codepot/views/taskbar.php b/codepot/src/codepot/views/taskbar.php index e2f7c881..6f015440 100644 --- a/codepot/src/codepot/views/taskbar.php +++ b/codepot/src/codepot/views/taskbar.php @@ -1,14 +1,16 @@ '; print '
'; - if (isset($loginid) && $loginid != '') + if (isset($login['id']) && $login['id'] != '') { - print anchor ('user/home', htmlspecialchars($loginid)); + $title = (isset($login['email']) && $login['email'] != '')? + ('title=' . htmlspecialchars($login['email'])): ''; + print anchor ('user/home', htmlspecialchars($login['id']), $title); $hex = $con->converter->AsciiToHex (current_url()); print anchor ("main/signout/{$hex}", $con->lang->line('Sign out')); @@ -39,14 +41,14 @@ function show_taskbar ($con, $loginid, $issysadmin) print '
'; print anchor ('site/home', $con->lang->line('Home')); print anchor ('project/catalog', $con->lang->line('Projects')); - if ($issysadmin) + if ($login['sysadmin?']) print anchor ('site/catalog', $con->lang->line('Administration')); print '
'; print '
'; } -show_taskbar ($this, $login['id'], $login['sysadmin?']); +show_taskbar ($this, $login); ?> diff --git a/codepot/src/config.php.in b/codepot/src/config.php.in index a5d9fd2c..0d17f3d0 100644 --- a/codepot/src/config.php.in +++ b/codepot/src/config.php.in @@ -46,6 +46,9 @@ function load_ini ($file) array ('ldap_server_protocol_version', 'integer', 3), array ('ldap_userid_format', 'string', '${userid}'), array ('ldap_password_format', 'string', '${password}'), + array ('ldap_mail_attribute_name', 'string', ''), + array ('ldap_admin_binddn', 'string', ''), + array ('ldap_admin_password', 'string', ''), array ('svnrepo_dir', 'string', CODEPOT_DEPOT_DIR.'/svnrepo'), array ('file_dir', 'string', CODEPOT_DEPOT_DIR.'/files'), diff --git a/codepot/src/css/Makefile.am b/codepot/src/css/Makefile.am index c91f2260..5d9f8506 100644 --- a/codepot/src/css/Makefile.am +++ b/codepot/src/css/Makefile.am @@ -7,6 +7,7 @@ www_DATA = \ file.css \ issue.css \ jquery-ui.css \ + log.css \ project.css \ site.css \ user.css \ diff --git a/codepot/src/css/Makefile.in b/codepot/src/css/Makefile.in index 45cebd5d..2a98f676 100644 --- a/codepot/src/css/Makefile.in +++ b/codepot/src/css/Makefile.in @@ -212,6 +212,7 @@ www_DATA = \ file.css \ issue.css \ jquery-ui.css \ + log.css \ project.css \ site.css \ user.css \ diff --git a/codepot/src/css/log.css b/codepot/src/css/log.css new file mode 100644 index 00000000..142c1e8a --- /dev/null +++ b/codepot/src/css/log.css @@ -0,0 +1,72 @@ +/* + * This file contains specific IDs for furthur customization. + */ + +/*----------------------------------------------- + * log view + *-----------------------------------------------*/ +#log_mainarea_result { + overflow: auto; +} + +#log_mainarea_result_table { + /*border-collapse: collapse;*/ + width: 100%; +} + +#log_mainarea_result_table a { + text-decoration: none; +} + +#log_mainarea_result_table td { + vertical-align: top; + white-space: nowrap; + padding-top: 3px; + padding-bottom: 3px; +} + +#log_mainarea_result_table td.break { + font-size: 0.5em; +} + +#log_mainarea_result_table td.date { + font-weight: bold; + background-color: #bbccef; +} + +#log_mainarea_result_table td.time { + width: 1px; + color: #777777; +} + +#log_mainarea_result_table td.projectid { + width: 1px; +} + +#log_mainarea_result_table td.object { + width: 1px; +} + +#log_mainarea_result_table td.details { + white-space: normal; +} + +#log_mainarea_result_table td.details .description { + /*font-style: italic;*/ +} + +#log_mainarea_result_table td.details pre.message { + border: 0; + margin: 1px; + background-color: inherit; + white-space: -moz-pre-wrap; + white-space: -o-pre-wrap; + white-space: pre-wrap; +} + +#log_mainarea_result_table td.pages { + padding-top: 1em; + text-align: center; + font-weight: bold; +} + diff --git a/codepot/src/css/project.css b/codepot/src/css/project.css index 1d699a3c..e8cedd2e 100644 --- a/codepot/src/css/project.css +++ b/codepot/src/css/project.css @@ -2,72 +2,6 @@ * This file contains specific IDs for furthur customization. */ -/*----------------------------------------------- - * log view - *-----------------------------------------------*/ -#log_mainarea_result { - overflow: auto; -} - -#log_mainarea_result_table { - //border-collapse: collapse; - width: 100%; -} - -#log_mainarea_result_table a { - text-decoration: none; -} - -#log_mainarea_result_table td { - vertical-align: top; - white-space: nowrap; - padding-top: 3px; - padding-bottom: 3px; -} - -#log_mainarea_result_table td.break { - font-size: 0.5em; -} - -#log_mainarea_result_table td.date { - font-weight: bold; - background-color: #bbccef; -} - -#log_mainarea_result_table td.time { - width: 1px; - color: #777777; -} - -#log_mainarea_result_table td.projectid { - width: 1px; -} - -#log_mainarea_result_table td.object { - width: 1px; -} - -#log_mainarea_result_table td.details { - white-space: normal; -} - -#log_mainarea_result_table td.details .description { - /*font-style: italic;*/ -} - -#log_mainarea_result_table td.details pre.message { - border: 0; - margin: 1px; - background-color: inherit; - white-space: pre-wrap; -} - -#log_mainarea_result_table td.pages { - padding-top: 1em; - text-align: center; - font-weight: bold; -} - /*----------------------------------------------- * project home view *-----------------------------------------------*/ @@ -79,33 +13,32 @@ background-color: #bbccef; } -#project_home_mainarea_sidebar_log_table tr.odd td { +#project_home_mainarea_sidebar_log_table tr.odd td.date { + width: 1%; white-space: nowrap; } -#project_home_mainarea_sidebar_log_table tr.odd td.date { - width: 1px; +#project_home_mainarea_sidebar_log_table tr.odd td.object { + white-space: nowrap; } #project_home_mainarea_sidebar_log_table tr.even { background-color: inherit; } -#project_home_mainarea_sidebar_log_table tr.even .description { +#project_home_mainarea_sidebar_log_table tr.even td.details .description { font-style: italic; } -#project_home_mainarea_sidebar_log_table tr.even pre.message { +#project_home_mainarea_sidebar_log_table tr.even td.details pre.message { border: 0; margin: 1px; background-color: inherit; + white-space: -moz-pre-wrap; + white-space: -o-pre-wrap; white-space: pre-wrap; } -#project_home_mainarea_sidebar_log_table td.date { - width: 1px; -} - /*----------------------------------------------- * project file edit view *-----------------------------------------------*/ diff --git a/codepot/src/css/site.css b/codepot/src/css/site.css index 4e37502f..443d34c1 100644 --- a/codepot/src/css/site.css +++ b/codepot/src/css/site.css @@ -13,37 +13,37 @@ background-color: #bbccef; } -#site_home_mainarea_sidebar_log_table tr.odd td { +#site_home_mainarea_sidebar_log_table tr.odd td.date { + width: 1%; white-space: nowrap; } -#site_home_mainarea_sidebar_log_table tr.odd td.date { - width: 1px; +#site_home_mainarea_sidebar_log_table tr.odd td.project { + width: 1%; + white-space: nowrap; +} + +#site_home_mainarea_sidebar_log_table tr.odd td.object { + white-space: nowrap; } #site_home_mainarea_sidebar_log_table tr.even { background-color: inherit; } -#site_home_mainarea_sidebar_log_table tr.even .description { +#site_home_mainarea_sidebar_log_table tr.even td.details .description { font-style: italic; } -#site_home_mainarea_sidebar_log_table tr.even pre.message { +#site_home_mainarea_sidebar_log_table tr.even td.details pre.message { border: 0; margin: 1px; - background-color: inherit; + background-color: inherit; + white-space: -moz-pre-wrap; + white-space: -o-pre-wrap; white-space: pre-wrap; } -#site_home_mainarea_sidebar_log_table td.date { - width: 1px; -} - -#site_home_mainarea_sidebar_log_table td.project { - width: 1px; -} - /*----------------------------------------------- * site edit view *-----------------------------------------------*/