Ejemplo n.º 1
0
 /**
  * @param int $issue_id
  * @param int $project_id
  * @param string $new_replier
  * @return string
  * @access protected
  */
 public function addAuthorizedReplier($issue_id, $project_id, $new_replier)
 {
     $usr_id = Auth::getUserID();
     $replier_usr_id = User::getUserIDByEmail($new_replier);
     // if this is an actual user, not just an email address check permissions
     if (!empty($replier_usr_id)) {
         // check if the assignee is even allowed to be in the given project
         $projects = Project::getRemoteAssocListByUser($replier_usr_id);
         if (!in_array($project_id, array_keys($projects))) {
             throw new RemoteApiException("The given user is not permitted in the project associated with issue #{$issue_id}");
         }
     }
     // check if user is already authorized
     if (Authorized_Replier::isAuthorizedReplier($issue_id, $new_replier)) {
         throw new RemoteApiException("The given user is already an authorized replier on issue #{$issue_id}");
     }
     $res = Authorized_Replier::remoteAddAuthorizedReplier($issue_id, $usr_id, $new_replier);
     if ($res == -1) {
         throw new RemoteApiException("Could not add '{$new_replier}' as an authorized replier to issue #{$issue_id}");
     }
     return 'OK';
 }
Ejemplo n.º 2
0
function addAuthorizedReplier($p)
{
    $email = XML_RPC_decode($p->getParam(0));
    $password = XML_RPC_decode($p->getParam(1));
    $auth = authenticate($email, $password);
    if (is_object($auth)) {
        return $auth;
    }
    $issue_id = XML_RPC_decode($p->getParam(2));
    $project_id = XML_RPC_decode($p->getParam(3));
    $new_replier = XML_RPC_decode($p->getParam(4));
    $usr_id = User::getUserIDByEmail($email);
    $replier_usr_id = User::getUserIDByEmail($new_replier);
    // if this is an actual user, not just an email address check permissions
    if (!empty($replier_usr_id)) {
        // check if the assignee is even allowed to be in the given project
        $projects = Project::getRemoteAssocListByUser($replier_usr_id);
        if (!in_array($project_id, array_keys($projects))) {
            return new XML_RPC_Response(0, $XML_RPC_erruser + 1, "The given user is not permitted in the project associated with issue #{$issue_id}");
        }
    }
    // check if user is already authorized
    if (Authorized_Replier::isAuthorizedReplier($issue_id, $new_replier)) {
        return new XML_RPC_Response(0, $XML_RPC_erruser + 1, "The given user is already an authorized replier on issue #{$issue_id}");
    }
    $res = Authorized_Replier::remoteAddAuthorizedReplier($issue_id, $usr_id, $new_replier);
    if ($res == -1) {
        return new XML_RPC_Response(0, $XML_RPC_erruser + 1, "Could not add '{$new_replier}' as an authorized replier to issue #{$issue_id}");
    } else {
        return new XML_RPC_Response(XML_RPC_Encode('OK'));
    }
}