/** * * @param WOOOF $wo * @param VO_TblMovieRamaUserMovies $obj * @param string $creatorId * @return false | id * */ public static function save(WOOOF $wo, VO_TblMovieRamaUserMovies &$obj, $creatorId) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: "); if (!$wo->hasContent($creatorId)) { $wo->logError(self::_ECP . "0654 No value provided for [creatorId]"); return false; } $tblMovieRamaUserMovies = new WOOOF_dataBaseTable($wo->db, 'movierama_user_movies'); if (!$tblMovieRamaUserMovies->constructedOk) { return false; } if (!$wo->hasContent($obj->id)) { //insert $obj->publishDateTime = $wo->currentGMTDateTime(); // insert new movie in table $newId = $tblMovieRamaUserMovies->insertRowFromArraySimple($obj->toArray()); if ($newId === FALSE) { return false; } $obj->id = $newId; } else { //update $updatedId = $tblMovieRamaUserMovies->updateRowFromArraySimple($obj->toArray()); if ($updatedId === FALSE) { return false; } $obj->id = $updatedId; } return $obj->id; }
/** * * @param WOOOF $wo * @param VO_TblPersonProfile $obj * @return false | id */ public static function savePersonProfile(WOOOF $wo, VO_TblPersonProfile &$obj) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: "); $t1 = new WOOOF_dataBaseTable($wo->db, 'person_profiles'); if (!$t1->constructedOk) { return false; } if ($wo->hasContent($obj->id)) { // update $obj->updatedDateTime = WOOOF::currentGMTDateTime(); $res = $t1->updateRowFromArraySimple($obj->toArray()); if ($res === FALSE) { return false; } } else { // insert $obj->isDeleted = '0'; $obj->createdDateTime = WOOOF::currentGMTDateTime(); $obj->updatedDateTime = $obj->createdDateTime; $newId = $t1->insertRowFromArraySimple($obj->toArray()); if ($newId === FALSE) { return false; } $obj->id = $newId; } return $obj->id; }
/** * * @param WOOOF $wo * @param VO_TblFlagItems $obj * @param char $action * @param bool $fetchBack * @return false | type of reported object * Returns actually saved $obj if $fetchBack is set to true */ public static function save(WOOOF $wo, VO_TblFlagItems &$obj, $action = 'I', $fetchBack = true) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: "); if (!$wo->hasContent($obj->flaggedByUserId)) { $wo->logError(self::_ECP . "3011 No value provided for [flaggedByUserId]"); return false; } if (!$wo->hasContent($obj->whatId)) { $wo->logError(self::_ECP . "3012 No value provided for [whatId]"); return false; } if (!$wo->hasContent($obj->whatType)) { $wo->logError(self::_ECP . "3013 No value provided for [whatType]"); return false; } if ($obj->flaggedByUserId === $obj->whatId) { $wo->logError(self::_ECP . "3014 Id's cannot be the same"); return false; } $tblFlagItems = new WOOOF_dataBaseTable($wo->db, 'flag_items'); if ($tblFlagItems === FALSE) { return false; } //insert if ($action === 'I') { $obj->flaggedDateTime = WOOOF::currentGMTDateTime(); $newId = $tblFlagItems->insertRowFromArraySimple($obj->toArray()); if ($newId === FALSE) { return false; } } else { $obj->flaggedDateTime = $wo->currentGMTDateTime(); $res = $tblFlagItems->updateRowFromArraySimple($obj->toArray()); if ($res === FALSE) { return false; } } return $obj->whatType; }
/** * @param WOOOF $wo * @param array $in [ id => evaluationId to close, * whatId => what id is being evaluated, whatType => what type is being evaluated * evalTemplateId => evaluation template id ] * @param string $requestorUserId * @return false | id */ public static function close(WOOOF $wo, $in, $requestorUserId) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: "); $tblEvaluations = new WOOOF_dataBaseTable($wo->db, 'evaluations'); if (!$tblEvaluations->constructedOk) { return false; } // Find the running evaluation in the table - Could me more than one???? $res = $tblEvaluations->getResult(['id' => $in['id'], 'evalTemplateId' => $in['evalTemplateId'], 'whatId' => $in['whatId'], 'whatType' => $in['whatType'], 'userId' => $requestorUserId, 'isRunning' => '1', 'isDeleted' => '0'], 'startDateTime', '', '', '', true, false); if ($res === FALSE) { return false; } if (!$wo->hasContent($tblEvaluations->resultRows)) { $wo->logError(self::_ECP . "2291 No row(s) with id {$in['id']} found in evaluations table!"); return false; } foreach ($tblEvaluations->resultRows as $aEvaluation) { $tblEvaluationUpdate = new VO_TblEvaluations($aEvaluation); $tblEvaluationUpdate->isRunning = '0'; $tblEvaluationUpdate->endDateTime = $wo->currentGMTDateTime(); $res = self::save($wo, $tblEvaluationUpdate); if ($res === FALSE) { return false; } } $calcRes = self::calcResults($wo, $in['id'], $requestorUserId); if ($calcRes === FALSE) { return false; } return $res; }