<?php
/**
- * Gforge group_join_request Facility
+ * FusionForge
*
- * Copyright 2005 (c) GForge Group
+ * Copyright 2005, GForge, LLC
+ * Copyright 2009, Roland Mas
*
- * @version $Id$
+ * This file is part of FusionForge.
*
- * This file is part of Gforge.
- *
- * Gforge 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 License, or
- * (at your option) any later version.
- *
- * Gforge 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.
+ * 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 License,
+ * 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 Gforge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
*/
require_once $gfcommon.'include/Error.class.php';
require_once $gfcommon.'include/Validator.class.php';
-/*
-function &groupjoinrequest_get_object($group_id,$user_id,$data=false) {
- global $GROUPJOINREQUEST_OBJ;
- if (!isset($GROUPJOINREQUEST_OBJ["_".$group_id."_".$user_id."_"])) {
- if ($data) {
- //the db result handle was passed in
- } else {
- $res=db_query("SELECT * FROM group_join_request
- WHERE group_id='$group_id' AND user_id='$user_id'");
-
- if (db_numrows($res) <1 ) {
- $GROUPJOINREQUEST_OBJ["_".$group_id."_".$user_id."_"]=false;
- return false;
- }
- $data =& db_fetch_array($res);
-
- }
- $grp =& group_get_object($group_id);
- $GROUPJOINREQUEST_OBJ["_".$group_id."_".$user_id."_"]= new GroupJoinRequest($grp,$user_id,$data);
-
- }
-
- return $GROUPJOINREQUEST_OBJ["_".$group_id."_".$user_id."_"];
-}
-*/
function &get_group_join_requests($Group) {
if (!$Group || !is_object($Group) || $Group->isError()) {
return false;
} else {
- $res=db_query("SELECT * FROM group_join_request WHERE group_id='".$Group->getID()."'");
+ $res = db_query_params ('SELECT * FROM group_join_request WHERE group_id=$1',
+ array ($Group->getID())) ;
while ($arr = db_fetch_array($res)) {
$reqs[] = new GroupJoinRequest($Group,$arr['user_id'],$arr);
}
function create($user_id,$comments) {
$v = new Validator();
$v->check($user_id, "user_id");
- //$v->check($comments, "comments");
+ $v->check(trim($comments), "comments");
if (!$v->isClean()) {
$this->setError($v->formErrorMsg("Must include "));
return false;
}
// Check if user is already a member of the project
- $perm =& $this->Group->getPermission( user_get_object($user_id) );
- if ($perm && is_object($perm) && $perm->isMember()) {
+ $result = db_query_params ('SELECT * FROM user_group WHERE group_id=$1 AND user_id=$2',
+ array ($this->Group->getID(),
+ $user_id)) ;
+ if (db_numrows($result)) {
$this->setError(_('You are already a member of this project.'));
return false;
}
// Check if user has already submitted a request
- $sql = "SELECT * FROM group_join_request WHERE group_id='".$this->Group->getID()."' AND user_id='".$user_id."'";
- $result = db_query($sql);
+ $result = db_query_params ('SELECT * FROM group_join_request WHERE group_id=$1 AND user_id=$2',
+ array ($this->Group->getID(),
+ $user_id)) ;
if (db_numrows($result)) {
$this->setError(_('You have already sent a request to the project administrators. Please wait for their reply.'));
return false;
db_begin();
- $sql="INSERT INTO group_join_request (group_id,user_id,comments,request_date)
- VALUES ('".$this->Group->getID()."','".$user_id."',
- '".addslashes(htmlspecialchars($comments))."','".time()."')";
- $result=db_query($sql);
+ $result = db_query_params ('INSERT INTO group_join_request (group_id,user_id,comments,request_date)
+ VALUES ($1, $2, $3, $4)',
+ array ($this->Group->getID(),
+ $user_id,
+ htmlspecialchars ($comments),
+ time())) ;
if (!$result || db_affected_rows($result) < 1) {
$this->setError('GroupJoinRequest::create() Posting Failed '.db_error());
db_rollback();
* @return boolean success.
*/
function fetchData($group_id,$user_id) {
- $res=db_query("SELECT * FROM group_join_request
- WHERE
- user_id='$user_id'
- AND group_id='". $this->Group->getID() ."'");
+ $res = db_query_params ('SELECT * FROM group_join_request WHERE user_id=$1 AND group_id=$2',
+ array ($user_id,
+ $this->Group->getID())) ;
if (!$res || db_numrows($res) < 1) {
$this->setError('GroupJoinRequest::fetchData() Invalid ID '.db_error());
return false;
* getID - get this GroupJoinRequest ID
*
* @return int The group_id.
- * /
+ */
function getID() {
return $this->data_array['group_id'];
}
* getComments - get the field comments.
*
* @return text The field.
- * /
+ */
function getComments() {
return $this->data_array['comments'];
}
$comments);
$body = str_replace("\\n","\n",$body);
- $ret = util_send_message($email,$subject,$body);
- if (! $ret) { return $ret; }
-
+ util_send_message($email,$subject,$body);
}
- setup_gettext_from_browser () ;
+ setup_gettext_from_context();
return true ;
}
$subject = sprintf(_('Request to Join Project %1$s'), $this->Group->getPublicName());
$body = sprintf(_('Your request to join the %1$s project was denied by an administrator.'), $this->Group->getPublicName());
util_send_message($user->getEmail(),$subject,$body);
- setup_gettext_from_browser () ;
+ setup_gettext_from_context();
return $this->delete(1);
}
$subject = sprintf(_('Request to Join Project %1$s'), $this->Group->getPublicName());
$body = sprintf(_('Your request to join the %1$s project was granted by an administrator.'), $this->Group->getPublicName());
util_send_message($user->getEmail(),$subject,$body);
- setup_gettext_from_browser () ;
+ setup_gettext_from_context();
}
/**
$this->setPermissionDeniedError();
return false;
} else {
- $res=db_query("DELETE FROM group_join_request WHERE
- group_id='".$this->Group->getID()."'
- AND user_id='".$this->getUserId()."'");
+ $res = db_query_params ('DELETE FROM group_join_request WHERE group_id=$1 AND user_id=$2',
+ array ($this->Group->getID(),
+ $this->getUserId()));
if (!$res || db_affected_rows($res) < 1) {
$this->setError('Could Not Delete: '.db_error());
} else {
}
}
-
// Local Variables:
// mode: php
// c-file-style: "bsd"