* otherwise return false;
*/
function get($variable) {
-
return $this->_get($variable, $this->params);
}
function _get($variable, $array) {
if ($this->_exist($variable, $array)) {
return $array[$variable];
- } else {
- return false;
}
+ return false;
}
/**
$this->_last_access_to_input[$idx][$variable] = $this->_getCallTrace();
if(is_array($this->params[$idx])) {
return $this->_get($variable, $this->params[$idx]);
- } else {
- return false;
}
+ return false;
}
function isAjax() {
function isPost() {
if($_SERVER['REQUEST_METHOD'] == 'POST') {
return true;
- } else {
- return false;
}
+ return false;
}
/**
if(is_a($validator, 'Valid_File')) {
$this->_validated_input[$validator->getKey()] = true;
return $validator->validate($_FILES, $validator->getKey());
- } else {
- return false;
}
+ return false;
}
/**
function _get($variable, $array) {
if ($this->_exist($variable, $array)) {
return $array[$variable];
- } else {
- return false;
}
+ return false;
}
}
while ($arr = db_fetch_array($res)) {
$result[] = user_get_object($arr['user_id']);
}
-
return $result;
}
array($user->getID(), $this->getID()));
if ($res && db_numrows($res)) {
return true;
- } else {
- return false;
}
+ return false;
}
function getID() { // From the PFO spec
$user = user_get_object($user_id);
if (!$user) {
return false;
- } else {
- return true;
}
+ return true;
}
/**
function isActive() {
if ($this->getStatus() == 'A') {
return true;
- } else {
- return false;
}
+ return false;
}
/**
$hidden = unserialize($this->data_array['hidden']);
if (is_array($hidden) && in_array($fieldName, $hidden)) {
return true;
- } else {
- return false;
}
+ return false;
}
/**
*/
/**
- * asciize() - Replace non-ascii characters with question marks
+ * asciize() - Replace non-ascii characters with question marks
*
- * LDAP expects utf-8 encoded character string. Since we cannot
- * know which encoding 8-bit characters in database use, we
- * just replace them with question marks.
+ * LDAP expects utf-8 encoded character string. Since we cannot
+ * know which encoding 8-bit characters in database use, we
+ * just replace them with question marks.
*
- * @param string $str UTF-8 encoded character string.
- * @return string which contains only ascii characters
+ * @param string $str UTF-8 encoded character string.
+ * @return string which contains only ascii characters
*/
function asciize($str) {
if (!$str) {
/**
* gfLdapConnect() - Connect to the LDAP server
*
- * @returns bool true on success/false on error
- *
+ * @returns bool true on success/false on error
*/
function gfLdapConnect() {
/**
* gfLdapAdd() - Wrapper for ldap_add()
*
- * @param string $dn dn
- * @param string $entry entry
- *
- * @return bool
+ * @param string $dn dn
+ * @param string $entry entry
+ * @return bool
*/
function gfLdapAdd($dn, $entry) {
global $ldap_conn;
/**
* gfLdapDelete() - Wrapper for ldap_delete()
*
- * @param string $dn dn
- *
- * @return bool
+ * @param string $dn dn
+ * @return bool
*/
function gfLdapDelete($dn) {
global $ldap_conn;
/**
* gfLdapModify() - Wrapper for ldap_modify()
*
- * @param string $dn dn
- * @param string $entry entry
- *
- * @return bool
+ * @param string $dn dn
+ * @param string $entry entry
+ * @return bool
*/
function gfLdapModify($dn,$entry) {
global $ldap_conn;
* gfLdapModifyIfExists() - Wrapper for ldap_modify()
* works like gfLdapModify, but returns true if the LDAP entry does not exist
*
- * @param string $dn dn
- * @param string $entry entry
- *
- * @return bool
+ * @param string $dn dn
+ * @param string $entry entry
+ * @return bool
*/
function gfLdapModifyIfExists($dn,$entry) {
- $res = $this->gfLdapModify($dn,$entry);
- if ($res) {
+ $res = $this->gfLdapModify($dn,$entry);
+ if ($res) {
+ return true ;
+ } else {
+ $err = ldap_errno ($ldap_conn) ;
+ if ($err == 32) {
return true ;
- } else {
- $err = ldap_errno ($ldap_conn) ;
- if ($err == 32) {
- return true ;
- } else {
- return false ;
- }
}
+ }
+ return false;
}
/**
* gfLdapModAdd() - Wrapper for ldap_mod_add()
*
- * @param string $dn dn
- * @param string $entry entry
- *
+ * @param string $dn dn
+ * @param string $entry entry
* @return bool
*/
function gfLdapModAdd($dn,$entry) {
/**
* gfLdapModDel() - Wrapper for ldap_mod_del()
*
- * @param string $dn dn
- * @param string $entry entry
- *
+ * @param string $dn dn
+ * @param string $entry entry
* @return bool
*/
function gfLdapModDel($dn,$entry) {
/**
* gfLdapRead() - Wrapper for ldap_read()
*
- * @param string $dn dn
- * @param string $filter filter
- * @param int $attrs attrs
- *
+ * @param string $dn dn
+ * @param string $filter filter
+ * @param int $attrs attrs
* @return resource
*/
function gfLdapRead($dn,$filter,$attrs=0) {
/**
* sysCheckUser() - Check for the existence of a user
*
- * @param int $user_id The user ID of the user to check
- * @return bool true on success/false on error
- *
+ * @param int $user_id The user ID of the user to check
+ * @return bool true on success/false on error
*/
function sysCheckUser($user_id) {
$user = user_get_object($user_id);
/**
* gfLdapcheck_user_by_name() - Check for a user by the username
*
- * @param string $user_name The username
- * @return bool true on success/false on error
- *
+ * @param string $user_name The username
+ * @return bool true on success/false on error
*/
function gfLdapcheck_user_by_name($user_name) {
global $ldap_conn;
*
* @param int $user_id The user ID of the user to create
* @return bool The return status of gfLdapcreate_user_from_object()
- *
*/
function sysCreateUser($user_id) {
// Check even if the user shouldn't exist
*
* @param int $user_id The ID of the user to check
* @return bool true on success/false on error
- *
*/
function sysCheckCreateUser($user_id) {
if (!$this->sysCheckUser($user_id)){
*
* @param object $user The user object
* @return bool true on success/false on error
- *
*/
function gfLdapcreate_user_from_object(&$user) {
/**
* gfLdapCreateUserFromProps() - Creates an LDAP user from
*
- * @param string $username The username
- * @param string $cn
- * @param string $crypt_pw The encrypted password
- * @param string $shell
- * @param string $cvsshell
- * @param int $uid
- * @param int $gid
- * @param string $email
- * @return bool true on success/false on error
- *
+ * @param string $username The username
+ * @param string $cn
+ * @param string $crypt_pw The encrypted password
+ * @param string $shell
+ * @param string $cvsshell
+ * @param int $uid
+ * @param int $gid
+ * @param string $email
+ * @return bool true on success/false on error
*/
function gfLdapCreateUserFromProps($username, $cn, $crypt_pw,
$shell, $cvsshell, $uid, $gid, $email) {
-
if (!$this->gfLdapConnect()) {
return false;
}
/**
* sysRemoveUser() - Remove an LDAP user
*
- * @param int $user_id The user ID of the user to remove
- * @return bool true on success/false on error
- *
+ * @param int $user_id The user ID of the user to remove
+ * @return bool true on success/false on error
*/
function sysRemoveUser($user_id) {
-
-
$user = user_get_object($user_id);
if (!$this->gfLdapConnect()) {
return false;
/**
* sysUserSetAttribute() - Set an attribute for a user
*
- * @param int $user_id The user ID
- * @param string $attr The attribute to set
- * @param string $value The new value of the attribute
- * @return bool true on success/false on error
- *
+ * @param int $user_id The user ID
+ * @param string $attr The attribute to set
+ * @param string $value The new value of the attribute
+ * @return bool true on success/false on error
*/
function sysUserSetAttribute($user_id,$attr,$value) {
-
-
$user = user_get_object($user_id);
if (!$this->gfLdapConnect()) {
return false;
/**
* sysCheckGroup() - Check for the existence of a group
*
- * @param int The ID of the group to check
- * @return bool true on success/false on error
- *
+ * @param int $group_id The ID of the group to check
+ * @return bool true on success/false on error
*/
function sysCheckGroup($group_id) {
global $ldap_conn;
/**
* sysCreateGroup() - Create a group
*
- * @param int The ID of the group to create
- * @return bool true on success/false on error
- *
+ * @param int $group_id The ID of the group to create
+ * @return bool true on success/false on error
*/
function sysCreateGroup($group_id) {
-
$group = group_get_object($group_id);
if (!$this->gfLdapConnect()) {
return false;
/**
* sysRemoveGroup() - Remove a group
*
- * @param int The ID of the group to remove
- * @return bool true on success/false on error
+ * @param int $group_id The ID of the group to remove
+ * @return bool true on success/false on error
*
*/
function sysRemoveGroup($group_id) {
-
$group = group_get_object($group_id);
if (!$this->gfLdapConnect()) {
return false;
/**
* sysGroupAddUser() - Add a user to an LDAP group
*
- * @param int $group_id The ID of the group two which the user will be added
- * @param int $user_id The ID of the user to add
- * @param bool $cvs_only Only add this user to CVS
- * @return bool true on success/false on error
- *
+ * @param int $group_id The ID of the group two which the user will be added
+ * @param int $user_id The ID of the user to add
+ * @param bool $cvs_only Only add this user to CVS
+ * @return bool true on success/false on error
*/
function sysGroupAddUser($group_id, $user_id, $cvs_only=false) {
global $ldap_conn;
/**
* sysGroupRemoveUser() - Remove a user from an LDAP group
*
- * @param int $group_id The ID of the group from which to remove the user
- * @param int $user_id The ID of the user to remove
- * @param bool $cvs_only Only remove user from CVS group
- * @return bool true on success/false on error
- *
+ * @param int $group_id The ID of the group from which to remove the user
+ * @param int $user_id The ID of the user to remove
+ * @param bool $cvs_only Only remove user from CVS group
+ * @return bool true on success/false on error
*/
function sysGroupRemoveUser($group_id, $user_id, $cvs_only=false) {
*
* @param int $user_id The user ID of the user to check
* @return bool true on success/false on error
- *
*/
function sysCheckUser($user_id) {
$user = user_get_object($user_id);
*
* @param int $user_id The user ID of the user to create
* @return bool success or not
- *
*/
function sysCreateUser($user_id) {
$user = user_get_object($user_id);
/**
* sysCheckCreateUser() - Check that a user has been created
*
- * @param int $user_id The ID of the user to check
+ * @param int $user_id The ID of the user to check
* @return bool true on success/false on error
- *
*/
function sysCheckCreateUser($user_id) {
return $this->sysCreateUser($user_id);
*
* @param int $group_id The ID of the group to check
* @return bool true on success/false on error
- *
*/
function sysCheckCreateGroup($group_id) {
return $this->sysCreateGroup($group_id);
*
* @param int $user_id The user ID of the user to remove
* @return bool true on success/false on failure
- *
*/
function sysRemoveUser($user_id) {
$res = db_query_params('UPDATE users SET unix_status=$1 WHERE user_id=$2',
/**
* sysUserSetAttribute() - Set an attribute for a user
*
- * @param int $user_id The user ID
+ * @param int $user_id The user ID
* @param string $attr The attribute to set
* @param string $value The new value of the attribute
- * @return bool true on success/false on error
- *
+ * @return bool true on success/false on error
*/
function sysUserSetAttribute($user_id,$attr,$value) {
// trigger nscd cache invalidation and scm-passwd regen through systasksd
/**
* sysCheckGroup() - Check for the existence of a group
*
- * @param int $group_id The ID of the group to check
- * @return bool true on success/false on error
- *
+ * @param int $group_id The ID of the group to check
+ * @return bool true on success/false on error
*/
function sysCheckGroup($group_id) {
$group = group_get_object($group_id);
array($group_id));
if (db_numrows($res) == 0){
return false;
- } else {
- return true;
}
}
+ return true;
}
/**
* sysCreateGroup() - Create a group
*
- * @param int $group_id The ID of the group to create
- * @return bool true on success/false on error
+ * @param int $group_id The ID of the group to create
+ * @return bool true on success/false on error
*
*/
function sysCreateGroup($group_id) {
if (forge_check_perm_for_user($u,'scm',$group_id,'read')) {
$res = db_query_params ('INSERT INTO nss_usergroups (
-SELECT users.unix_uid AS uid,
- groups.group_id + $1 AS gid,
- users.user_id AS user_id,
- groups.group_id AS group_id,
- users.user_name AS user_name,
- groups.unix_group_name||$2 AS unix_group_name
-FROM users,groups
-WHERE users.user_id=$3
- AND users.status=$4
- AND users.unix_status=$5
- AND groups.status=$6
- AND groups.group_id=$7)',
+ SELECT users.unix_uid AS uid,
+ groups.group_id + $1 AS gid,
+ users.user_id AS user_id,
+ groups.group_id AS group_id,
+ users.user_name AS user_name,
+ groups.unix_group_name||$2 AS unix_group_name
+ FROM users,groups
+ WHERE users.user_id=$3
+ AND users.status=$4
+ AND users.unix_status=$5
+ AND groups.status=$6
+ AND groups.group_id=$7)',
array($this->GID_ADD_SCMRO,
'_scmro',
$user_id,
if (forge_check_perm_for_user($u,'scm',$group_id,'write')) {
$res = db_query_params ('INSERT INTO nss_usergroups (
-SELECT users.unix_uid AS uid,
- groups.group_id + $1 AS gid,
- users.user_id AS user_id,
- groups.group_id AS group_id,
- users.user_name AS user_name,
- groups.unix_group_name||$2 AS unix_group_name
-FROM users,groups
-WHERE users.user_id=$3
- AND users.status=$4
- AND users.unix_status=$5
- AND groups.status=$6
- AND groups.group_id=$7)',
+ SELECT users.unix_uid AS uid,
+ groups.group_id + $1 AS gid,
+ users.user_id AS user_id,
+ groups.group_id AS group_id,
+ users.user_name AS user_name,
+ groups.unix_group_name||$2 AS unix_group_name
+ FROM users,groups
+ WHERE users.user_id=$3
+ AND users.status=$4
+ AND users.unix_status=$5
+ AND groups.status=$6
+ AND groups.group_id=$7)',
array($this->GID_ADD_SCMRW,
'_scmrw',
$user_id,
if ($u->isMember($p)) {
$res = db_query_params ('INSERT INTO nss_usergroups (
-SELECT users.unix_uid AS uid,
- groups.group_id + $1 AS gid,
- users.user_id AS user_id,
- groups.group_id AS group_id,
- users.user_name AS user_name,
- groups.unix_group_name AS unix_group_name
-FROM users,groups
-WHERE users.user_id=$2
- AND users.status=$3
- AND users.unix_status=$4
- AND groups.status=$5
- AND groups.group_id=$6)',
+ SELECT users.unix_uid AS uid,
+ groups.group_id + $1 AS gid,
+ users.user_id AS user_id,
+ groups.group_id AS group_id,
+ users.user_name AS user_name,
+ groups.unix_group_name AS unix_group_name
+ FROM users,groups
+ WHERE users.user_id=$2
+ AND users.status=$3
+ AND users.unix_status=$4
+ AND groups.status=$5
+ AND groups.group_id=$6)',
array ($this->GID_ADD,
$user_id,
'A', 'A', 'A',
}
$sql = "
-INSERT INTO nss_usergroups
-
--- Member access
-SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text
-FROM users
- JOIN pfo_user_role USING (user_id)
- JOIN pfo_role ON (pfo_user_role.role_id=pfo_role.role_id)
- LEFT JOIN role_project_refs ON (pfo_user_role.role_id=role_project_refs.role_id)
- JOIN nss_groups ON (pfo_role.home_group_id=nss_groups.group_id)
-WHERE users.unix_status='A' AND nss_groups.gid < $1
-
-UNION
-
--- Read access
-SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text
-FROM users
- JOIN pfo_user_role USING (user_id)
- JOIN pfo_role ON (pfo_user_role.role_id=pfo_role.role_id)
- LEFT JOIN role_project_refs ON (pfo_user_role.role_id=role_project_refs.role_id)
- JOIN nss_groups ON (pfo_role.home_group_id=nss_groups.group_id OR role_project_refs.group_id=nss_groups.group_id)
- JOIN pfo_role_setting ON (pfo_user_role.role_id=pfo_role_setting.role_id AND (pfo_role_setting.ref_id=nss_groups.group_id) AND ((section_name='project_admin' AND perm_val=1) OR (section_name='scm' AND perm_val>=1)))
-WHERE users.unix_status='A' AND nss_groups.gid > $2
-
-UNION
-
--- Write access
-SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text
-FROM users
- JOIN pfo_user_role USING (user_id)
- JOIN pfo_role ON (pfo_user_role.role_id=pfo_role.role_id)
- LEFT JOIN role_project_refs ON (pfo_user_role.role_id=role_project_refs.role_id)
- JOIN nss_groups ON (pfo_role.home_group_id=nss_groups.group_id OR role_project_refs.group_id=nss_groups.group_id)
- JOIN pfo_role_setting ON (pfo_user_role.role_id=pfo_role_setting.role_id AND (pfo_role_setting.ref_id=nss_groups.group_id) AND ((section_name='project_admin' AND perm_val=1) OR (section_name='scm' AND perm_val=2)))
-WHERE users.unix_status='A' AND nss_groups.gid > $1 AND nss_groups.gid < $2
-
-UNION
-
--- Forge admins
-SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text
-FROM users
- JOIN pfo_user_role USING (user_id)
- JOIN pfo_role_setting ON (pfo_user_role.role_id=pfo_role_setting.role_id AND section_name='forge_admin' AND perm_val=1), nss_groups
-WHERE users.unix_status='A'
-
--- Not supported, this is not sane
--- UNION
---
--- -- 'Open' privileges for Anonymous and LoggedIn users
--- SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text||'_scmro'
--- FROM users
--- JOIN role_project_refs ON (role_project_refs.role_id IN (1,2))
--- JOIN nss_groups ON (role_project_refs.group_id=nss_groups.group_id)
--- JOIN pfo_role_setting ON (role_project_refs.role_id=pfo_role_setting.role_id AND (pfo_role_setting.ref_id=nss_groups.group_id) AND ((section_name='project_admin' AND perm_val=1) OR (section_name='scm' AND perm_val=2)))
--- WHERE users.unix_status='A' AND nss_groups.gid < $1
-
-GROUP BY users.user_id, nss_groups.gid;
-";
+ INSERT INTO nss_usergroups
+
+ -- Member access
+ SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text
+ FROM users
+ JOIN pfo_user_role USING (user_id)
+ JOIN pfo_role ON (pfo_user_role.role_id=pfo_role.role_id)
+ LEFT JOIN role_project_refs ON (pfo_user_role.role_id=role_project_refs.role_id)
+ JOIN nss_groups ON (pfo_role.home_group_id=nss_groups.group_id)
+ WHERE users.unix_status='A' AND nss_groups.gid < $1
+
+ UNION
+
+ -- Read access
+ SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text
+ FROM users
+ JOIN pfo_user_role USING (user_id)
+ JOIN pfo_role ON (pfo_user_role.role_id=pfo_role.role_id)
+ LEFT JOIN role_project_refs ON (pfo_user_role.role_id=role_project_refs.role_id)
+ JOIN nss_groups ON (pfo_role.home_group_id=nss_groups.group_id OR role_project_refs.group_id=nss_groups.group_id)
+ JOIN pfo_role_setting ON (pfo_user_role.role_id=pfo_role_setting.role_id AND (pfo_role_setting.ref_id=nss_groups.group_id) AND ((section_name='project_admin' AND perm_val=1) OR (section_name='scm' AND perm_val>=1)))
+ WHERE users.unix_status='A' AND nss_groups.gid > $2
+
+ UNION
+
+ -- Write access
+ SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text
+ FROM users
+ JOIN pfo_user_role USING (user_id)
+ JOIN pfo_role ON (pfo_user_role.role_id=pfo_role.role_id)
+ LEFT JOIN role_project_refs ON (pfo_user_role.role_id=role_project_refs.role_id)
+ JOIN nss_groups ON (pfo_role.home_group_id=nss_groups.group_id OR role_project_refs.group_id=nss_groups.group_id)
+ JOIN pfo_role_setting ON (pfo_user_role.role_id=pfo_role_setting.role_id AND (pfo_role_setting.ref_id=nss_groups.group_id) AND ((section_name='project_admin' AND perm_val=1) OR (section_name='scm' AND perm_val=2)))
+ WHERE users.unix_status='A' AND nss_groups.gid > $1 AND nss_groups.gid < $2
+
+ UNION
+
+ -- Forge admins
+ SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text
+ FROM users
+ JOIN pfo_user_role USING (user_id)
+ JOIN pfo_role_setting ON (pfo_user_role.role_id=pfo_role_setting.role_id AND section_name='forge_admin' AND perm_val=1), nss_groups
+ WHERE users.unix_status='A'
+
+ -- Not supported, this is not sane
+ -- UNION
+ --
+ -- -- 'Open' privileges for Anonymous and LoggedIn users
+ -- SELECT users.unix_uid, nss_groups.gid, users.user_id, nss_groups.group_id, user_name, nss_groups.name::text||'_scmro'
+ -- FROM users
+ -- JOIN role_project_refs ON (role_project_refs.role_id IN (1,2))
+ -- JOIN nss_groups ON (role_project_refs.group_id=nss_groups.group_id)
+ -- JOIN pfo_role_setting ON (role_project_refs.role_id=pfo_role_setting.role_id AND (pfo_role_setting.ref_id=nss_groups.group_id) AND ((section_name='project_admin' AND perm_val=1) OR (section_name='scm' AND perm_val=2)))
+ -- WHERE users.unix_status='A' AND nss_groups.gid < $1
+
+ GROUP BY users.user_id, nss_groups.gid;
+ ";
$res = db_query_params($sql, array($this->GID_ADD_SCMRW, $this->GID_ADD_SCMRO));
if (!$res) {
$this->setError('Error: cannot regen nss_usergroups: '.db_error());
/**
* util_is_valid_filename - Verifies whether a file has a valid filename
+ * TODO: check to rename and use only 1 function: see util_is_valid_repository_name
*
* @param string $file The file to verify
* @return bool true on success/false on error
if (!empty($invalidchars)) {
return false;
- } else {
- if (strstr($file, '..')) {
- return false;
- } else {
- return true;
- }
}
+ if (strstr($file, '..')) {
+ return false;
+ }
+ return true;
}
/**
//
// Now set up our internal data structures
//
- if (!$this->fetchData($id)) {
- return false;
- } else {
+ if ($this->fetchData($id)) {
return true;
}
+ return false;
} else {
$this->setError(db_error());
return false;
function initialSetup() {
$this->createTables();
- if (!$this->initialData()) {
- return false;
- } else {
+ if ($this->initialData()) {
return true;
}
+ return false;
+ }
}
function createTables() {
function isAutoAssign() {
if ($this->getArtifactType()->getAutoAssignField() == $this->getID()) {
return true;
- } else {
- return false;
}
+ return false;
}
/**
$user_id)) ;
if (db_numrows($res)>0) {
return true;
- } else {
- return false;
}
+ return false;
}
}
function isValid($val) {
if(preg_match('/^(\d{1,4})-(\d{1,2})-(\d{1,2}?)$/', $val, $m)) {
return checkdate($m[2], $m[3], $m[1]);
- } else {
- return false;
}
+ return false;
}
}
function checkFormat($val) {
if(preg_match('/^([+-]?[1-9][0-9]*|[+-]?0)$/', $val)) {
return true;
- } else {
- return false;
}
+ return false;
}
function isValid($val) {
// Check (-2^31;2^31-1) range
if(strval(intval($val)) == $val) {
return true;
- } else {
- return false;
}
- } else {
- return false;
}
+ return false;
}
}
$this->saved_login = '';
$this->saved_user = NULL;
- $this->delegatedAuthentifier = FALSE;
+ $this->delegatedAuthentifier = false;
- $this->webid_identity = FALSE;
+ $this->webid_identity = false;
$this->declareConfigVars();
// The IdP to use is configured in the .ini file
$this->delegate_webid_auth_to = forge_get_config('delegate_webid_auth_to', $this->name);
$this->idp_delegation_link = forge_get_config('idp_delegation_link', $this->name);
-
}
/**
* @param string $message : alternative message for the link
* @return string html
*/
- function displayAuthentifyViaIdPLink($callback, $message = FALSE) {
+ function displayAuthentifyViaIdPLink($callback, $message = false) {
if (!$message) {
$message = sprintf( _('Click here to delegate authentication of your WebID to %s'), $this->delegate_webid_auth_to);
}
* @return string
*/
public function getUserNameFromWebIDIdentity($webid_identity) {
- $user_name = FALSE;
+ $user_name = false;
$res = db_query_params('SELECT users.user_name FROM users, plugin_authwebid_user_identities WHERE users.user_id = plugin_authwebid_user_identities.user_id AND webid_identity=$1',
array($webid_identity));
if($res) {
$res = db_query_params('SELECT webid_identity FROM plugin_authwebid_user_identities WHERE webid_identity =$1',
array($webid_identity));
if ($res && db_numrows($res) > 0) {
- return TRUE;
- }
- else {
- return FALSE;
+ return true;
}
+ return false;
}
/**
if ($res && db_numrows($res) > 0) {
$arr = db_fetch_array($res);
if ($arr[0] == '1') {
- return TRUE;
- } else {
- return FALSE;
+ return true;
}
- } else {
- return FALSE;
}
+ return false;
}
/**
*/
// We don't rely on the PHP session, as we're in FusionForge
- $create_session = FALSE;
+ $create_session = false;
//$this->delegatedAuthentifier = new Authentication_Delegated($create_session, NULL, NULL, $certRepository);
$this->delegatedAuthentifier = new Authentication_Delegated($create_session);
* @return string
*/
public function getCurrentWebID() {
- $webid = FALSE;
+ $webid = false;
if ($this->delegatedAuthentifier) {
$webid = $this->delegatedAuthentifier->webid;
}
*
* @return boolean
*/
- function activationRequested()
- {
+ function activationRequested() {
$systemevent = SystemEventManager::instance();
$result1 = $systemevent->fetchEvents(0,10,false,SystemEvent::STATUS_NEW,'MAILMAN_LIST_CREATE',$this->getID());
$result2 = $systemevent->fetchEvents(0,10,false,SystemEvent::STATUS_RUNNING,'MAILMAN_LIST_CREATE',$this->getID());
if(count($result1)+count($result2)<1) {
return false;
- } else {
- return true;
}
+ return true;
}
/**
*
* @return bool
*/
- function recreate()
- {
+ function recreate() {
$systemevent = SystemEventManager::instance();
$systemevent->createEvent('MAILMAN_LIST_CREATE', $this->getID(),SystemEvent::PRIORITY_MEDIUM);
}
if (db_numrows($resIdProjetMantis) > 0) {
return true;
- } else {
- return false;
}
+ return false;
}
/**
<?php
-
-class OAuthProvider {
+/*
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+class OAuthProvider {
protected $id;
protected $name;
protected $authorize_url;
protected $access_token_url;
- function __construct($name, $description, $consumer_key, $consumer_secret, $request_token_url, $authorize_url, $access_token_url, $id = 0) {
+ function __construct($name, $description, $consumer_key, $consumer_secret, $request_token_url, $authorize_url, $access_token_url, $id = 0) {
$this->id = $id;
$this->name = $name;
$this->description = $description;
$this->access_token_url = $access_token_url;
}
- public function get_id() {
+ public function get_id() {
return $this->id;
}
- protected function set_id($id) {
+ protected function set_id($id) {
$this->id = $id;
}
return $this->name;
}
- public function get_description() {
+ public function get_description() {
return $this->description;
}
- public function get_consumer_key() {
+ public function get_consumer_key() {
return $this->consumer_key;
}
- public function get_consumer_secret() {
+ public function get_consumer_secret() {
return $this->consumer_secret;
}
- public function get_request_token_url() {
+ public function get_request_token_url() {
return $this->request_token_url;
}
- public function get_authorize_url() {
+ public function get_authorize_url() {
return $this->authorize_url;
}
- public function get_access_token_url() {
+ public function get_access_token_url() {
return $this->access_token_url;
}
$this->name = $name;
}
- public function set_description($description) {
+ public function set_description($description) {
$this->description = $description;
}
- public function set_consumer_key($consumer_key) {
+ public function set_consumer_key($consumer_key) {
$this->consumer_key = $consumer_key;
}
- public function set_consumer_secret($consumer_secret) {
+ public function set_consumer_secret($consumer_secret) {
$this->consumer_secret = $consumer_secret;
}
- public function set_request_token_url($request_token_url) {
+ public function set_request_token_url($request_token_url) {
$this->request_token_url = $request_token_url;
}
- public function set_authorize_url($authorize_url) {
+ public function set_authorize_url($authorize_url) {
$this->authorize_url = $authorize_url;
}
- public function set_access_token_url($access_token_url) {
+ public function set_access_token_url($access_token_url) {
$this->access_token_url = $access_token_url;
}
- static function convert_row_to_object($row) {
+ static function convert_row_to_object($row) {
if ($row!=null) {
$provider = new OAuthProvider($row['name'], $row['description'], $row['consumer_key'], $row['consumer_secret'], $row['request_token_url'], $row['authorize_url'], $row['access_token_url'], $row['id']);
return $provider;
- } else {
- return null;
}
+ return null;
}
static function get_provider($id) {
return $providers;
}
- static function check_provider_values($new=TRUE, $name, $description, $consumer_key, $consumer_secret, $request_token_url, $authorize_url, $access_token_url) {
+ static function check_provider_values($new=TRUE, $name, $description, $consumer_key, $consumer_secret, $request_token_url, $authorize_url, $access_token_url) {
if (!trim($name)) {
return "The field 'Name' is empty! ";
} elseif (!trim($description)) {
return "The Authorization URL is not valid.";
} elseif (trim($access_token_url) && (!preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $access_token_url))) {
return "The Access Token URL is not valid.";
- } else {
- return null;
}
+ return null;
}
- static function provider_exists($name) {
+ static function provider_exists($name) {
$conn = FFOAuthDataStore::singleton();
$row = $conn->find_provider_from_name($name);
if($row==null) {
return false;
}
- else {
- return true;
- }
+ return true;
}
function write_to_db() {
$id = $conn->save_provider($this);
if(!$id) {
exit_error("Error trying to add new oauth provider to DB", 'oauthconsumer');
- }else {
+ } else {
$this->set_id($id);
}
}
- function delete() {
+ function delete() {
$conn = FFOAuthDataStore::singleton();
$id = $this->get_id();
if ($id!=0) {
return "The name '".$p_consumer_name."' has already been taken. Please choose another!";
} elseif (!preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $p_consumer_url)) {
return "The Consumer URL is not valid.";
- } else {
- return null;
}
+ return null;
}
/**
$t_consumer = new OauthAuthzConsumer( $t_row['name'], $t_row['consumer_key'], $t_row['consumer_secret'], $t_row['consumer_url'], $t_row['consumer_desc'], $t_row['consumer_email'] );
$t_consumer->setId($t_row['id']);
return $t_consumer;
- } else {
- return null;
}
+ return null;
}
/**
$t_row = $DBSTORE->find_consumer_from_name($p_consumer_name);
if ($t_row==null) {
return false;
- } else {
- return true;
}
-
+ return true;
}
/**
}
if (strpos($haystack, $needle) !== false) {
return true;
- } else {
- return false;
}
+ return false;
}
function show($text) {
function browser_is_mac() {
if (browser_get_platform()=='Mac') {
return true;
- } else {
- return false;
}
+ return false;
}
function browser_is_windows() {
if (browser_get_platform()=='Win') {
return true;
- } else {
- return false;
}
+ return false;
}
function browser_is_ie() {
if (browser_get_agent()=='IE') {
return true;
- } else {
- return false;
}
+ return false;
}
function browser_is_netscape() {
if (browser_get_agent()=='MOZILLA') {
return true;
- } else {
- return false;
}
+ return false;
}
/*
} else {
$GLOBALS['BROWSER_PLATFORM']='Other';
}
-
-/*
-echo "\n\nAgent: ".getStringFromServer('HTTP_USER_AGENT');
-echo "\nIE: ".browser_is_ie();
-echo "\nMac: ".browser_is_mac();
-echo "\nWindows: ".browser_is_windows();
-echo "\nPlatform: ".browser_get_platform();
-echo "\nVersion: ".browser_get_version();
-echo "\nAgent: ".browser_get_agent();
-*/
$result=db_query_params('SELECT * FROM people_job WHERE job_id=$1 AND group_id=$2', array($job_id, $group_id));
if (!$result || db_numrows($result) < 1) {
return false;
- } else {
- return true;
}
+ return true;
}
function people_get_skill_name($skill_id) {
$states = db_query_params ('select * from doc_states',
array ());
for ($row=0; $row<db_numrows($states); $row++) {
- $return[]=array(
- 'state_id' => db_result($states, $row, 'stateid'),
- 'description' => db_result($states, $row, 'name')
- );
- }
+ $return[]=array(
+ 'state_id' => db_result($states, $row, 'stateid'),
+ 'description' => db_result($states, $row, 'name')
+ );
+ }
return $return;
}
function validateState($state_id) {
$res = db_query_params ('SELECT name FROM doc_states WHERE stateid=$1',
array ($state_id));
- if(db_numrows($res)==1) {
+ if (db_numrows($res)==1) {
return true;
- } else {
- return false;
}
+ return false;
}
//
if (!$d->create($uploaded_data_name, $uploaded_data_type, $file, $doc_group, $title, $description)) {
return new soap_fault('', 'addDocument', $d->getErrorMessage(), $d->getErrorMessage());
- } else {
- return $d->getID();
}
+ return $d->getID();
}
//
if (!$d->update($uploaded_data_name, $uploaded_data_type, $file, $doc_group, $title, $description, $state_id)) {
return new soap_fault('', 'updateDocument', $d->getErrorMessage(), $d->getErrorMessage());
- } else {
- return true;
}
-
+ return true;
}
//
}
if (!$dg->create($groupname, $parent_doc_group)) {
return new soap_fault('', 'addDocumentGroup', 'Could Not Create Document Group','Could Not Create Document Group');
- } else {
- return $dg->getID();
}
+ return $dg->getID();
}
//
if (!$dg->update($new_groupname, $new_parent_doc_group)) {
return new soap_fault('', 'updateDocumentGroup', $dg->getErrorMessage(), $dg->getErrorMessage());
- } else {
- return true;
}
+ return true;
}
//
if (!$d->delete()) {
return new soap_fault('', 'documentDelete', $d->getErrorMessage(), $d->getErrorMessage());
- } else {
- return true;
}
+ return true;
}