Example #1
0
 /**
  * Method used to get all issues associated with a status that doesn't have
  * the 'closed' context.
  *
  * @param   integer $prj_id The project ID to list issues from
  * @param   integer $usr_id The user ID of the user requesting this information
  * @param   boolean $show_all_issues Whether to show all open issues, or just the ones assigned to the given email address
  * @param   integer $status_id The status ID to be used to restrict results
  * @return  array The list of open issues
  */
 public static function getOpenIssues($prj_id, $usr_id, $show_all_issues, $status_id)
 {
     $projects = Project::getRemoteAssocListByUser($usr_id);
     if (count($projects) == 0) {
         return '';
     }
     $stmt = 'SELECT
                 iss_id,
                 iss_summary,
                 sta_title
              FROM
                 (
                 {{%issue}},
                 {{%status}}
                 )
              LEFT JOIN
                 {{%issue_user}}
              ON
                 isu_iss_id=iss_id
              WHERE ';
     $params = array();
     if (!empty($status_id)) {
         $stmt .= ' sta_id=? AND ';
         $params[] = $status_id;
     }
     $stmt .= '
                 iss_prj_id=? AND
                 sta_id=iss_sta_id AND
                 sta_is_closed=0';
     $params[] = $prj_id;
     if ($show_all_issues == false) {
         $stmt .= ' AND
                 isu_usr_id=?';
         $params[] = $usr_id;
     }
     $stmt .= "\nGROUP BY\n                        iss_id";
     try {
         $res = DB_Helper::getInstance()->getAll($stmt, $params);
     } catch (DbException $e) {
         return '';
     }
     if (count($res) > 0) {
         self::getAssignedUsersByIssues($res);
     }
     return $res;
 }
Example #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'));
    }
}
Example #3
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';
 }
Example #4
0
 /**
  * Method used to get all issues associated with a status that doesn't have
  * the 'closed' context.
  *
  * @access  public
  * @param   integer $prj_id The project ID to list issues from
  * @param   integer $usr_id The user ID of the user requesting this information
  * @param   boolean $show_all_issues Whether to show all open issues, or just the ones assigned to the given email address
  * @param   integer $status_id The status ID to be used to restrict results
  * @return  array The list of open issues
  */
 function getOpenIssues($prj_id, $usr_id, $show_all_issues, $status_id)
 {
     $prj_id = Misc::escapeInteger($prj_id);
     $status_id = Misc::escapeInteger($status_id);
     $projects = Project::getRemoteAssocListByUser($usr_id);
     if (@count($projects) == 0) {
         return '';
     }
     $stmt = "SELECT\n                    iss_id,\n                    iss_summary,\n                    sta_title\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n                 LEFT JOIN\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n                 ON\n                    isu_iss_id=iss_id\n                 WHERE ";
     if (!empty($status_id)) {
         $stmt .= " sta_id={$status_id} AND ";
     }
     $stmt .= "\n                    iss_prj_id={$prj_id} AND\n                    sta_id=iss_sta_id AND\n                    sta_is_closed=0";
     if ($show_all_issues == false) {
         $stmt .= " AND\n                    isu_usr_id={$usr_id}";
     }
     $stmt .= "\nGROUP BY\n                        iss_id";
     $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return '';
     } else {
         if (count($res) > 0) {
             Issue::getAssignedUsersByIssues($res);
         }
         return $res;
     }
 }