function analyseResourceCalendarVCard($string, $pimfile)
{
    verbose("Analyzing Resource Calendar VCard for File '" . $pimfile . "'");
    $c = str_replace("\r", "\n", $string);
    $c = str_replace("\n\n", "\n", $c);
    verbose("Analysing '" . $pimfile . "'");
    $c = explode("\n", $c);
    for ($i = 0; $i < count($GLOBALS["fields"]["calendar"]); $i++) {
        if ($GLOBALS["fields"]["calendar"][$i] != "pimfile") {
            ${$GLOBALS["fields"]["calendar"][$i]} = "";
        }
    }
    for ($i = 0; $i < count($c); $i++) {
        if (strtoupper(substr($c[$i], 0, 4)) == "UID:") {
            $x = explode(":", $c[$i]);
            $ar["uid"] = $x[1];
        }
        if (strtoupper(substr($c[$i], 0, 7)) == "DTSTART") {
            $x = explode(":", $c[$i]);
            $ar["from"] = checkTimeStamp(str_replace("T", "", str_replace("Z", "", $x[1])));
        }
        if (strtoupper(substr($c[$i], 0, 5)) == "DTEND") {
            $x = explode(":", $c[$i]);
            $ar["to"] = checkTimeStamp(str_replace("T", "", str_replace("Z", "", $x[1])));
        }
        if (strtoupper(substr($c[$i], 0, 7)) == "SUMMARY") {
            $x = explode(":", $c[$i]);
            $ar["summary"] = $x[1];
        }
    }
    return $ar;
}
function analyseResourceTodo($folder)
{
    $d = opendir($folder);
    while ($f = readdir($d)) {
        if ($f != "." && $f != ".." && str_replace(".svn", "", $f) != "") {
            $pimfile = str_replace("//", "/", $folder . "/" . $f);
            $fp = fopen($pimfile, "r");
            $c = "";
            while (!feof($fp)) {
                $c .= fgets($fp, 9999);
            }
            fclose($fp);
            $c = str_replace("\r", "\n", $c);
            $c = str_replace("\n\n", "\n", $c);
            verbose("Analysing '" . $pimfile . "'");
            $c = explode("\n", $c);
            for ($i = 0; $i < count($GLOBALS["fields"]["todo"]); $i++) {
                if ($GLOBALS["fields"]["todo"][$i] != "pimfile") {
                    ${$GLOBALS["fields"]["todo"][$i]} = "";
                }
            }
            for ($i = 0; $i < count($c); $i++) {
                if (strtoupper(substr($c[$i], 0, 4)) == "UID:") {
                    $x = explode(":", $c[$i]);
                    $uid = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 3)) == "DUE") {
                    $x = explode(":", $c[$i]);
                    $due = checkTimeStamp(str_replace("T", "", str_replace("Z", "", $x[1])));
                }
                if (strtoupper(substr($c[$i], 0, 7)) == "SUMMARY") {
                    $x = explode(":", $c[$i]);
                    $summary = $x[1];
                }
            }
            $id = count($GLOBALS["restree"]["todo"]);
            for ($i = 0; $i < count($GLOBALS["fields"]["todo"]); $i++) {
                $GLOBALS["restree"]["todo"][$id][$GLOBALS["fields"]["todo"][$i]] = ${$GLOBALS["fields"]["todo"][$i]};
            }
            $GLOBALS["restree"]["todo"][$id][internalid] = $id;
        }
    }
}
function analyseResourceContact($folder)
{
    $d = opendir($folder);
    while ($f = readdir($d)) {
        if ($f != "." && $f != ".." && str_replace(".svn", "", $f) != "") {
            $pimfile = str_replace("//", "/", $folder . "/" . $f);
            $fp = fopen($pimfile, "r");
            $c = "";
            while (!feof($fp)) {
                $c .= fgets($fp, 9999);
            }
            fclose($fp);
            $c = str_replace("\r", "\n", $c);
            $c = str_replace("\n\n", "\n", $c);
            verbose("Analysing '" . $pimfile . "'");
            $c = explode("\n", $c);
            for ($i = 0; $i < count($GLOBALS["fields"]["contact"]); $i++) {
                if ($GLOBALS["fields"]["contact"][$i] != "pimfile") {
                    ${$GLOBALS["fields"]["contact"][$i]} = "";
                }
            }
            for ($i = 0; $i < count($c); $i++) {
                if (strtoupper(substr($c[$i], 0, 4)) == "UID:") {
                    $x = explode(":", $c[$i]);
                    $uid = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 2)) == "N:") {
                    $x = explode(":", $c[$i]);
                    $x = explode(";", $x[1]);
                    $surname = $x[0];
                    $firstname = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 5)) == "BDAY:") {
                    $x = explode(":", $c[$i]);
                    $birthday = checkTimeStamp(str_replace("T", "", str_replace("Z", "", $x[1])));
                }
                if (strtoupper(substr($c[$i], 0, 6)) == "EMAIL:") {
                    $x = explode(":", $c[$i]);
                    $email = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 4)) == "URL:") {
                    $x = explode(":", $c[$i]);
                    $url = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 6)) == "TITLE:") {
                    $x = explode(":", $c[$i]);
                    $title = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 4)) == "ORG:") {
                    $x = explode(":", $c[$i]);
                    $organization = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 5)) == "NOTE:") {
                    $x = explode(":", $c[$i]);
                    $note = $x[1];
                }
                if (strtoupper(substr($c[$i], 0, 4)) == "TEL;") {
                    $x = explode(";", $c[$i]);
                    for ($y = 0; $y < count($x); $y++) {
                        $nr = explode(":", $x[$y]);
                        switch ($nr[0]) {
                            case "TYPE=HOME":
                                $telephone = $nr[1];
                                break;
                            case "TYPE=VOICE":
                                $mobilephone = $nr[1];
                                break;
                            case "TYPE=CELL":
                                $cellphone = $nr[1];
                                break;
                            case "TYPE=FAX":
                                $fax = $nr[1];
                                break;
                        }
                    }
                }
            }
            $id = count($GLOBALS["restree"]["contact"]);
            for ($i = 0; $i < count($GLOBALS["fields"]["contact"]); $i++) {
                $GLOBALS["restree"]["contact"][$id][$GLOBALS["fields"]["contact"][$i]] = ${$GLOBALS["fields"]["contact"][$i]};
            }
            $GLOBALS["restree"]["contact"][$id][internalid] = $id;
        }
    }
}
 /**
  * Reports a result for a single test case
  *
  * @param struct $args
  * @param string $args["devKey"]
  * @param int $args["testcaseid"]: optional, if not present           
  *                                 testcaseexternalid must be present
  *
  * @param int $args["testcaseexternalid"]: optional, if does not is present           
  *                                         testcaseid must be present
  *
  *
  *
  * @param int $args["testplanid"] 
  * @param string $args["status"] - status is {@link $validStatusList}
  * @param int $args["buildid"] - optional.
  *                               if not present and $args["buildname"] exists
  *                               then 
  *                                    $args["buildname"] will be checked and used if valid
  *                               else 
  *                                    build with HIGHEST ID will be used
  *
  * @param int $args["buildname"] - optional.
  *                               if not present Build with higher internal ID will be used
  *
  *
  * @param string $args["notes"] - optional
  * @param string $args["execduration"] - optional
  *
  * @param bool $args["guess"] - optional defining whether to guess optinal params or require them 
  *                               explicitly default is true (guess by default)
  *
  * @param string $args["bugid"] - optional
  *
  * @param string $args["platformid"] - optional, if not present platformname must be present
  * @param string $args["platformname"] - optional, if not present platformid must be present
  *    
  *
  * @param string $args["customfields"] - optional
  *               contains an map with key:Custom Field Name, value: value for CF.
  *               VERY IMPORTANT: value must be formatted in the way it's written to db,
  *               this is important for types like:
  *
  *               DATE: strtotime()
  *               DATETIME: mktime()
  *               MULTISELECTION LIST / CHECKBOX / RADIO: se multipli selezione ! come separatore
  *
  *
  *               these custom fields must be configured to be writte during execution.
  *               If custom field do not meet condition value will not be written
  *
  * @param boolean $args["overwrite"] - optional, if present and true, then last execution
  *                for (testcase,testplan,build,platform) will be overwritten.            
  *
  * @param boolean $args["user"] - optional, if present and user is a valid login 
  *                                (no other check will be done) it will be used when writting execution.
  *
  * @param string $args["timestamp"] - optional, if not present now is used
  *                                    format YYYY-MM-DD HH:MM:SS
  *                                    example 2015-05-22 12:15:45   
  * @return mixed $resultInfo 
  *         [status]  => true/false of success
  *         [id]      => result id or error code
  *         [message]  => optional message for error message string
  * @access public
  *
  * @internal revisions
  *
  */
 public function reportTCResult($args)
 {
     $resultInfo = array();
     $operation = __FUNCTION__;
     $msg_prefix = "({$operation}) - ";
     $this->errors = null;
     $this->_setArgs($args);
     $resultInfo[0]["status"] = true;
     $checkFunctions = array('authenticate', 'checkTestCaseIdentity', 'checkTestPlanID', 'checkBuildID', 'checkStatus');
     $status_ok = $this->_runChecks($checkFunctions, $msg_prefix);
     if ($status_ok) {
         // This check is needed only if test plan has platforms
         $platformSet = $this->tplanMgr->getPlatforms($this->args[self::$testPlanIDParamName], array('outputFormat' => 'map'));
         $targetPlatform = null;
         if (!is_null($platformSet)) {
             $status_ok = $this->checkPlatformIdentity($this->args[self::$testPlanIDParamName], $platformSet, $msg_prefix);
             if ($status_ok) {
                 $targetPlatform[$this->args[self::$platformIDParamName]] = $platformSet[$this->args[self::$platformIDParamName]];
             }
         }
         $status_ok = $status_ok && $this->_checkTCIDAndTPIDValid($targetPlatform, $msg_prefix);
     }
     $tester_id = null;
     if ($status_ok) {
         $this->errors = null;
         if ($this->_isParamPresent(self::$userParamName)) {
             $tester_id = tlUser::doesUserExist($this->dbObj, $this->args[self::$userParamName]);
             if (!($status_ok = !is_null($tester_id))) {
                 $msg = $msg_prefix . sprintf(NO_USER_BY_THIS_LOGIN_STR, $this->args[self::$userParamName]);
                 $this->errors[] = new IXR_Error(NO_USER_BY_THIS_LOGIN, $msg);
             }
         }
     }
     $exec_ts = null;
     if ($status_ok) {
         if ($this->_isParamPresent(self::$timeStampParamName)) {
             // Now check if is a valid one
             $exec_ts = $this->args[self::$timeStampParamName];
             try {
                 checkTimeStamp($exec_ts);
                 $exec_ts = "'{$exec_ts}'";
             } catch (Exception $e) {
                 $status_ok = false;
                 $this->errors = null;
                 $msg = $msg_prefix . sprintf(INVALID_TIMESTAMP_STR, $exec_ts);
                 $this->errors[] = new IXR_Error(INVALID_TIMESTAMP, $msg);
             }
         }
     }
     if ($status_ok && $this->userHasRight("testplan_execute", self::CHECK_PUBLIC_PRIVATE_ATTR)) {
         $executionID = 0;
         $resultInfo[0]["operation"] = $operation;
         $resultInfo[0]["overwrite"] = false;
         $resultInfo[0]["status"] = true;
         $resultInfo[0]["message"] = GENERAL_SUCCESS_STR;
         if ($this->_isParamPresent(self::$overwriteParamName) && $this->args[self::$overwriteParamName]) {
             $executionID = $this->_updateResult($tester_id, $exec_ts);
             $resultInfo[0]["overwrite"] = true;
         }
         if ($executionID == 0) {
             $executionID = $this->_insertResultToDB($tester_id, $exec_ts);
         }
         $resultInfo[0]["id"] = $executionID;
         // Do we need to insert a bug ?
         if ($this->_isParamPresent(self::$bugIDParamName)) {
             $bugID = $this->args[self::$bugIDParamName];
             $resultInfo[0]["bugidstatus"] = $this->_insertExecutionBug($executionID, $bugID);
         }
         if ($this->_isParamPresent(self::$customFieldsParamName)) {
             $resultInfo[0]["customfieldstatus"] = $this->_insertCustomFieldExecValues($executionID);
         }
         return $resultInfo;
     } else {
         return $this->errors;
     }
 }
示例#5
0
 /**
  * Reports a result for a single test case
  *
  * @param struct $args
  * @param string $args["devKey"]
  * @param int $args["testcaseid"]: optional, if not present           
  *                                 testcaseexternalid must be present
  *
  * @param int $args["testcaseexternalid"]: optional, if does not is present           
  *                                         testcaseid must be present
  *
  *
  *
  * @param int $args["testplanid"] 
  * @param string $args["status"] - status is {@link $validStatusList}
  * @param int $args["buildid"] - optional.
  *                               if not present and $args["buildname"] exists
  *                               then 
  *                                    $args["buildname"] will be checked and used if valid
  *                               else 
  *                                    build with HIGHEST ID will be used
  *
  * @param int $args["buildname"] - optional.
  *                               if not present Build with higher internal ID will be used
  *
  *
  * @param string $args["notes"] - optional
  * @param string $args["execduration"] - optional
  *
  * @param bool $args["guess"] - optional defining whether to guess optinal params or require them 
  *                               explicitly default is true (guess by default)
  *
  * @param string $args["bugid"] - optional
  *
  * @param string $args["platformid"] - optional, if not present platformname must be present
  * @param string $args["platformname"] - optional, if not present platformid must be present
  *    
  *
  * @param string $args["customfields"] - optional
  *               contains an map with key:Custom Field Name, value: value for CF.
  *               VERY IMPORTANT: value must be formatted in the way it's written to db,
  *               this is important for types like:
  *
  *               DATE: strtotime()
  *               DATETIME: mktime()
  *               MULTISELECTION LIST / CHECKBOX / RADIO: se multipli selezione ! come separatore
  *
  *
  *               these custom fields must be configured to be writte during execution.
  *               If custom field do not meet condition value will not be written
  *
  * @param boolean $args["overwrite"] - optional, if present and true, then last execution
  *                for (testcase,testplan,build,platform) will be overwritten.            
  *
  * @param boolean $args["user"] - optional, if present and user is a valid login 
  *                                (no other check will be done) it will be used when writting execution.
  *
  * @param string $args["timestamp"] - optional, if not present now is used
  *                                    format YYYY-MM-DD HH:MM:SS
  *                                    example 2015-05-22 12:15:45   
  * @return mixed $resultInfo 
  *         [status]  => true/false of success
  *         [id]      => result id or error code
  *         [message]  => optional message for error message string
  * @access public
  *
  * @internal revisions
  *
  */
 public function reportTCResult($args)
 {
     $resultInfo = array();
     $operation = __FUNCTION__;
     $msg_prefix = "({$operation}) - ";
     $this->errors = null;
     $this->_setArgs($args);
     $resultInfo[0]["status"] = true;
     $checkFunctions = array('authenticate', 'checkTestCaseIdentity', 'checkTestPlanID', 'checkBuildID', 'checkStatus');
     $status_ok = $this->_runChecks($checkFunctions, $msg_prefix);
     if ($status_ok) {
         // This check is needed only if test plan has platforms
         $platformSet = $this->tplanMgr->getPlatforms($this->args[self::$testPlanIDParamName], array('outputFormat' => 'map'));
         $targetPlatform = null;
         if (!is_null($platformSet)) {
             $status_ok = $this->checkPlatformIdentity($this->args[self::$testPlanIDParamName], $platformSet, $msg_prefix);
             if ($status_ok) {
                 $targetPlatform[$this->args[self::$platformIDParamName]] = $platformSet[$this->args[self::$platformIDParamName]];
             }
         }
         $status_ok = $status_ok && $this->_checkTCIDAndTPIDValid($targetPlatform, $msg_prefix);
     }
     $tester_id = null;
     if ($status_ok) {
         $this->errors = null;
         if ($this->_isParamPresent(self::$userParamName)) {
             $tester_id = tlUser::doesUserExist($this->dbObj, $this->args[self::$userParamName]);
             if (!($status_ok = !is_null($tester_id))) {
                 $msg = $msg_prefix . sprintf(NO_USER_BY_THIS_LOGIN_STR, $this->args[self::$userParamName]);
                 $this->errors[] = new IXR_Error(NO_USER_BY_THIS_LOGIN, $msg);
             }
         }
     }
     $exec_ts = null;
     if ($status_ok) {
         if ($this->_isParamPresent(self::$timeStampParamName)) {
             // Now check if is a valid one
             $exec_ts = $this->args[self::$timeStampParamName];
             try {
                 checkTimeStamp($exec_ts);
                 $exec_ts = "'{$exec_ts}'";
             } catch (Exception $e) {
                 $status_ok = false;
                 $this->errors = null;
                 $msg = $msg_prefix . sprintf(INVALID_TIMESTAMP_STR, $exec_ts);
                 $this->errors[] = new IXR_Error(INVALID_TIMESTAMP, $msg);
             }
         }
     }
     if ($status_ok && $this->userHasRight("testplan_execute", self::CHECK_PUBLIC_PRIVATE_ATTR)) {
         $executionID = 0;
         $resultInfo[0]["operation"] = $operation;
         $resultInfo[0]["overwrite"] = false;
         $resultInfo[0]["status"] = true;
         $resultInfo[0]["message"] = GENERAL_SUCCESS_STR;
         if ($this->_isParamPresent(self::$overwriteParamName) && $this->args[self::$overwriteParamName]) {
             $executionID = $this->_updateResult($tester_id, $exec_ts);
             $resultInfo[0]["overwrite"] = true;
         }
         if ($executionID == 0) {
             $executionID = $this->_insertResultToDB($tester_id, $exec_ts);
         }
         $resultInfo[0]["id"] = $executionID;
         // Do we need to insert a bug ?
         if ($this->_isParamPresent(self::$bugIDParamName)) {
             $bugID = $this->args[self::$bugIDParamName];
             $resultInfo[0]["bugidstatus"] = $this->_insertExecutionBug($executionID, $bugID);
         }
         if ($this->_isParamPresent(self::$customFieldsParamName)) {
             $resultInfo[0]["customfieldstatus"] = $this->_insertCustomFieldExecValues($executionID);
         }
         //
         if ($executionID > 0 && !$resultInfo[0]["overwrite"]) {
             // Get steps info
             // step number, result, notes
             if ($this->_isParamPresent(self::$stepsParamName)) {
                 $resultInfo[0]["steps"] = 'yes!';
                 $st =& $this->args[self::$stepsParamName];
                 foreach ($st as $sp) {
                     $nst[$sp['step_number']] = $sp;
                 }
                 $r2d2 = array('fields2get' => 'TCSTEPS.step_number,TCSTEPS.id', 'accessKey' => 'step_number', 'renderGhostSteps' => false, 'renderImageInline' => false);
                 // return array('tcx' => $this->tcVersionID); //gretel
                 $steps = $this->tcaseMgr->getStepsSimple($this->tcVersionID, 0, $r2d2);
                 $target = DB_TABLE_PREFIX . 'execution_tcsteps';
                 $resultsCfg = config_get('results');
                 foreach ($nst as $spnum => $spdata) {
                     // check if step exists, if not ignore
                     if (isset($steps[$spnum])) {
                         // if result is not on domain, write it
                         // anyway.
                         $status = strtolower(trim($spdata['result']));
                         $status = $status[0];
                         $sql = " INSERT INTO {$target} (execution_id,tcstep_id,notes";
                         $sql .= ",status";
                         $values = " VALUES ( {$executionID}, {$steps[$spnum]['id']}," . "'" . $this->dbObj->prepare_string($spdata['notes']) . "'";
                         $values .= ",'" . $this->dbObj->prepare_string($status) . "'";
                         $sql .= ") " . $values . ")";
                         if ($status != $resultsCfg['status_code']['not_run']) {
                             $this->dbObj->exec_query($sql);
                         }
                     }
                 }
             }
         }
         return $resultInfo;
     } else {
         return $this->errors;
     }
 }