/** * * @param WOOOF $wo * @param id $movieRamaUserId * @return false | array[ ] */ public static function getMainInfo(WOOOF $wo, $movieRamaUserId) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: [{$movieRamaUserId}]"); $main = []; if ($movieRamaUserId == $wo->app->userId) { $ramaUser = $wo->app->movieRamaPersonRow; $main['isSelf'] = true; } else { $ramaUser = $wo->db->getRowByColumn('v_movierama_persons', 'VUS_id', $movieRamaUserId); if ($ramaUser === FALSE || $ramaUser === NULL) { return false; } $main['isSelf'] = false; } $main['personProfileId'] = $ramaUser['VUS_personProfileId']; $main['movieRamaUserId'] = $ramaUser['VUS_id']; $main['isActive'] = $ramaUser['VUS_isActive']; $main['isLoggedIn'] = true; $main['isType'] = 'PRS'; $main['avatarImg'] = $ramaUser['VUS_avatarImg']; $mainElems = ['PROF_firstName', 'PROF_lastName']; WOOOF_Util::filterOnKeys($main, $mainElems, $ramaUser, 'PROF_'); return $main; }
/** * * @param WOOOF $wo * @param array $in * @return false | flagged item type */ public static function saveFlagItem(WOOOF $wo, $movieramaUserId, $in) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: "); //find if user has already flagged the movie once before $tblFlagItems = new WOOOF_dataBaseTable($wo->db, 'flag_items'); if (!$tblFlagItems->constructedOk) { return false; } $res = $tblFlagItems->getResult(['whatId' => $in['whatId'], 'whatType' => $in['whatType'], 'flaggedByUserId' => $movieramaUserId, 'flagStatus' => 'P', 'isDeleted' => '0'], '', '', '', '', false, true); if ($res === FALSE) { return false; } foreach ($tblFlagItems->resultRows as $aFlagItem) { $tblFlagItemUpdate = new VO_TblFlagItems($aFlagItem); $tblFlagItemUpdate->flagText = $in['flagText']; $res = self::save($wo, $tblFlagItemUpdate, 'U'); if ($res === FALSE) { return false; } return $res; } $tblFlagItemInsert = new VO_TblFlagItems(); $tblFlagItemInsert->whatType = $in['whatType']; $tblFlagItemInsert->whatId = $in['whatId']; $tblFlagItemInsert->flaggedByUserId = $movieramaUserId; $tblFlagItemInsert->flagText = $in['flagText']; $tblFlagItemInsert->flagStatus = 'P'; $res = self::save($wo, $tblFlagItemInsert, 'I'); if ($res === FALSE) { return false; } return $res; }
function initAppMOVIERAMA(WOOOF $wo) { $wo->debug("Initialising MOVIERAMA App..."); $appObject = new VO_App(); $userId = $appObject->initFor($wo); if ($userId === FALSE) { return FALSE; } $wo->app = $appObject; spl_autoload_register(function ($className) { VO_App::handleClassAutoloader($className, WOOOF::$instance); }); return TRUE; }
public static function loadAll(WOOOF $wo) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: "); $po_error_message = ''; $l_error_message = ''; $t1 = new WOOOF_dataBaseTable($wo->db, 'sys_params'); if (!$t1->constructedOk) { return false; } $res = $t1->getResult(['isdeleted' => 0], 'code'); if ($res === FALSE) { return false; } foreach ($t1->resultRows as $aRow) { $l_res[strtoupper($aRow['code'])] = array(self::convertToType($aRow['paramValue'], $aRow['paramDataType']), $aRow['paramDataType']); } self::$params = $l_res; return true; }
/** * * @param WOOOF $wo * @param array $in * @return boolean */ public static function passwordChange(WOOOF $wo, $in) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: ChangePassword"); $movieRamaPerson = $wo->db->getRowByColumn('v_movierama_persons', 'VUS_id', $in['movieRamaUserId']); if ($movieRamaPerson === FALSE) { return false; } if ($movieRamaPerson === NULL) { $wo->logError(self::_ECP . "3352 No MovieRama person found."); return false; } $user = $wo->db->getRow('__users', $movieRamaPerson['VUS_userId']); if ($user === FALSE) { return false; } if ($user === NULL) { $wo->logError(self::_ECP . "3357 No user found."); return false; } //change password here $passwordErrors = []; $res = WOOOF_User::changePassword($wo, $user['loginName'], $in['newPass'], $passwordErrors, $in['oldPass']); if ($res === FALSE) { return false; } return $res; }
/** * * @param WOOOF $wo * @param string $externalFileId * @param string $handle // Optional, default 'file transfer'. * @return NO RETURN|false|string // send file to browser, fail, or return contents as string */ public static function getExternalFileById(WOOOF $wo, $externalFileId, $fileData = null, $handle = 'file transfer') { // TODO: CAUTION: Assume that rights are checked ??? // 00200 $wo->debug("getExternalFileById [{$externalFileId}] [{$handle}]"); if ($fileData == NULL && !$wo->hasContent($externalFileId)) { $wo->logError(self::_ECP . "00200 No value provided for 'externalFileId'."); return FALSE; } if ($fileData == NULL) { $result = $wo->db->query('select * from __externalFiles where id=\'' . $externalFileId . '\''); if (mysqli_num_rows($result) != 1) { $wo->logError(self::_ECP . "00210 Malformed file location. Specified PAYLOAD location [{$externalFileId}] is invalid!"); return FALSE; } $fileData = $wo->db->fetchAssoc($result); } $absoluteFilesRepositoryPath = $wo->getConfigurationFor('absoluteFilesRepositoryPath'); $fullFilename = $absoluteFilesRepositoryPath . $fileData['fileName']; if (!file_exists($fullFilename)) { $wo->logError(self::_ECP . "00220 File [{$fullFilename}] was not found!"); return FALSE; } if ($handle == 'file transfer') { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($fileData['originalFileName'])); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($absoluteFilesRepositoryPath . $fileData['fileName'])); ob_clean(); flush(); $succ = readfile($fullFilename); // TODO: Check for FALSE ... ?? exit; } // file transfer return file_get_contents($fullFilename); }
/** * * @param WOOOF $wo * @param string $id for record to be deleted * @param string $action ('unLike' | 'unHate') * @return id of row deleted */ public static function deleteOpinion(WOOOF $wo, $id, $action) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: Delete Movie Opinion"); if (!$wo->hasContent($id)) { $wo->logError(self::_ECP . "1909 No value provided for [id]"); return false; } $tblUserMovieOpinions = new WOOOF_dataBaseTable($wo->db, 'movierama_user_movies_opinions'); if (!$tblUserMovieOpinions->constructedOk) { return false; } //find movie id to update counter $movieOpinionRec = $wo->db->getRow('movierama_user_movies_opinions', $id); if ($movieOpinionRec === FALSE) { return false; } $res = $tblUserMovieOpinions->deleteRow($id); if ($res === FALSE) { return false; } if ($action === 'unLike') { $decreaseLike = self::updateCounter($wo, $movieOpinionRec['movieId'], 'noOfLikes', '-1'); if ($decreaseLike === FALSE) { return false; } } else { if ($action === 'unHate') { $decreaseHate = self::updateCounter($wo, $movieOpinionRec['movieId'], 'noOfHates', '-1'); if ($decreaseHate === FALSE) { return false; } } } return $id; }
/** * * @param WOOOF $wo * @param string $whatType * @param string $requestorUserId * @param array $otherData // optional. TBD * @return false | array[ [ 'label', 'value' ], ... ] */ public static function getTemplates(WOOOF $wo, $whatType, $requestorUserId) { // 4000 $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: [{$whatType}] [{$requestorUserId}]"); if ($wo->hasContent($whatType)) { $where1 = "\twhatType = '{$whatType}'"; } $sql = "\n\t\tselect id as `value`, concat('[', description, '] for ', whatType) as `label`\n\t\tfrom eval_templates\n\t\twhere\n\t\t{$where1} and\n\t\tisSystemDefined = '1' and\n\t\tisDeleted = '0'\n\t\torder by 2"; $res = $wo->db->getResultByQuery($sql, true, false); if ($res === FALSE) { return FALSE; } return $wo->db->resultRows; }
/** * * @param WOOOF $wo * @param array $in * @return boolean */ public static function tokenResend(WOOOF $wo, $in) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->debug("{$place}: ReseendVerificationToken"); $movieramaUserRec = $wo->db->getRowByColumn('movierama_users', 'username', $in['email']); if ($movieramaUserRec === FALSE) { return false; } if ($movieramaUserRec === NULL) { $wo->logError(self::_ECP . "2370 No such user found."); return false; } if ($wo->hasContent($movieramaUserRec['verificationToken'])) { $succ = VO_Users::handleVerificationToken($wo, $movieramaUserRec['id'], $movieramaUserRec['username'], $movieramaUserRec['verificationToken']); if ($succ === FALSE) { return FALSE; } } else { $wo->logError(self::_ECP . "2380 It seems you have already been verified."); return false; } return $succ; }