/** * loads the object's attributes. * loads the object's attributes by giving a SID as parameter * @param $id the id of the querycaches row */ public function load_With_SID($id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("ams_querycache", array('id' => $id), "SID=:id"); $row = $statement->fetch(); $this->set($row); }
/** * loads the object's attributes. * loads the object's attributes by giving a ticket_content's id, * @param $id the id of the ticket_content entry that should be loaded */ public function load_With_TContentId($id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("ticket_content", array('id' => $id), "TContentId=:id"); $row = $statement->fetch(); $this->tContentId = $row['TContentId']; $this->content = $row['Content']; }
/** * Local Hook to get database content * which is called by the global hook * by passing a parameter * * Hook to get the player stats of the character * * @param $data array with respective information * @return $row extracted db content wrt $data */ function hook_get_player_stat($data) { // returns the character id with respect to the character name in the ring_tool->characters $db = new DBLayer('webig'); $sth = $db->select('players', array('name' => $data), 'name=:name'); $row = $sth->fetch(); return $row; }
/** * loads the object's attributes. * loads the object's attributes by giving a categories id. * @param $id the id of the ticket_category that should be loaded */ public function load_With_TCategoryId($id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("ticket_category", array('id' => $id), "TCategoryId=:id"); $row = $statement->fetch(); $this->tCategoryId = $row['TCategoryId']; $this->name = $row['Name']; }
/** * Check if user is in in_support_group. * @param $user_id the id of the user. * @param $group_id the id of the support group. * @return true is returned in case the user is in the support group, else false is returned. */ public static function userExistsInSGroup($user_id, $group_id) { $dbl = new DBLayer("lib"); //check if name is already used if ($dbl->select("in_support_group", array('user_id' => $user_id, 'group_id' => $group_id), "`User` = :user_id and `Group` = :group_id")->rowCount()) { return true; } else { return false; } }
private function getLatestMigration() { $sql = "SELECT migration from migrations order by migration desc limit 1"; $res = DBLayer::select($sql); $r = mysql_fetch_assoc($res); if ($r['migration'] == "") { return 0; } else { return $r['migration']; } }
/** * loads the object's attributes. * loads the object's attributes by giving a ticket_id, it will put the matching user_id and the ticket_id into the attributes. * @param $ticket_id the id of the ticket that should be loaded */ public function load($ticket_id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("`assigned`", array('ticket_id' => $ticket_id), "`Ticket` = :ticket_id"); $row = $statement->fetch(); $this->set($row); }
/** * loads the object's attributes. * loads the object's attributes by giving a TId (ticket id). * @param $id the id of the ticket that should be loaded */ public function load_With_TId($id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("ticket", array('id' => $id), "TId=:id"); $row = $statement->fetch(); $this->tId = $row['TId']; $this->timestamp = $row['Timestamp']; $this->title = $row['Title']; $this->status = $row['Status']; $this->queue = $row['Queue']; $this->ticket_category = $row['Ticket_Category']; $this->author = $row['Author']; $this->priority = $row['Priority']; }
/** * function to check for updates or * if the same plugin already exists * also, if the update founds ,check for the UpdateInfo in the .info file. * Update is saved in the temp directory with pluginName_version.zip * * @param $fileName file which is uploaded in .zip extension * @param $findPath where we have to look for the installed plugins * @param $tempFile path for the temporary file * @param $tempPath path where we have to store the update * @return 2 if plugin already exists and update not found * @return 3 if update info tag not found in .info file */ function checkForUpdate($fileName, $findPath, $tempFile, $tempPath) { // check for plugin if exists $file = scandir($findPath); foreach ($file as $key => $value) { if (strcmp($value, $fileName) == 0) { if (!file_exists($tempPath . "/test")) { mkdir($tempPath . "/test"); } // extracting the update if (zipExtraction($tempFile, $tempPath . "/test/")) { $result = readPluginFile(".info", $tempPath . "/test/" . $fileName); // check for the version for the plugin $db = new DBLayer("lib"); $sth = $db->select("plugins", array('Name' => $result['PluginName']), "Name = :Name"); $info = $sth->fetch(); $info['Info'] = json_decode($info['Info']); // the two versions from main plugin and the updated part $new_version = explode('.', $result['Version']); $pre_version = explode('.', $info['Info']->Version); // For all plugins we have used semantic versioning // Format: X.Y.Z ,X->Major, Y->Minor, Z->Patch // change in the X Y & Z values refer the type of change in the plugin. // for initial development only Minor an Patch MUST be 0. // if there is bug fix then there MUST be an increment in the Z value. // if there is change in the functionality or addition of new functionality // then there MUST be an increment in the Y value. // When there is increment in the X value , Y and Z MUST be 0. // comparing if there is some change if (!array_diff($new_version, $pre_version)) { // removing the uploaded file Plugincache::rrmdir($tempPath . "/test/" . $fileName); return '2'; //plugin already exists } else { // check for update info if exists if (!array_key_exists('UpdateInfo', $result)) { return '3'; //update info tag not found } else { // check if update already exists if (pluginUpdateExists($info['Id'], $tempPath . "/" . trim($fileName, ".zip") . "_" . $result['Version'] . ".zip")) { echo "Update already exists"; throw new SystemExit(); } else { // removing the preivous update $dbr = new DBLayer("lib"); $dbr->delete("updates", array('id' => $info['Id']), "PluginId=:id"); // storing update in the temp directory // format of update save if (move_uploaded_file($tempFile, $tempPath . "/" . trim($fileName, ".zip") . "_" . $result['Version'] . ".zip")) { // setting update information in the database $update['PluginId'] = $info['Id']; $update['UpdatePath'] = $tempPath . "/" . trim($fileName, ".zip") . "_" . $result['Version'] . ".zip"; $update['UpdateInfo'] = json_encode($result); $dbr->insert("updates", $update); header("Cache-Control: max-age=1"); header("Location: index.php?page=plugins&result=7"); throw new SystemExit(); } } } } } } } }
/** * Global Hook to load the data from db and set it * into the global array to return it to the template */ function api_key_management_hook_load_db() { global $var_set; global $API_key_management_return_set; $dbl = new DBLayer("lib"); if (isset($_SESSION['user'])) { // returns the registered keys $sth = $dbl->select('ams_api_keys', array('user' => $_SESSION['user']), 'User = :user'); $row = $sth->fetchAll(); $API_key_management_return_set['api_keys'] = $row; // fetch the character from the array to compare $com = array_column($API_key_management_return_set['api_keys'], 'UserCharacter'); // returns the characters with respect to the user id in the ring_tool->characters try { $dbl = new DBLayer('ring'); $sth = $dbl->selectWithParameter('char_name', 'characters', array(), '1'); $row = $sth->fetch(); // loop through the character list and remove the character if already have an api key $API_key_management_return_set['characters'] = array_diff($row, $com); } catch (PDOException $e) { error_log($e->getMessage()); } } }
/** * loads the object's attributes. * loads the object's attributes by giving a group id, it will put the matching groups attributes in the object. * @param $id the id of the support group that should be loaded */ public function load_With_SGroupId($id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("`support_group`", array('id' => $id), "`SGroupId` = :id"); $row = $statement->fetch(); $this->set($row); }
/** * loads the object's attributes by using a ticket's id. * loads the object's attributes by giving a ticket's entry id. * @param $id the id of the ticket, the ticket_info entry of that ticket should be loaded. */ public function load_With_Ticket($id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("ticket_info", array('id' => $id), "Ticket=:id"); $row = $statement->fetch(); $this->set($row); }
/** * loads the object's attributes. * loads the object's attributes by giving a ticket_reply's id. * @param $id the id of the ticket_reply that should be loaded */ public function load_With_TReplyId($id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("ticket_reply", array('id' => $id), "TReplyId=:id"); $row = $statement->fetch(); $this->tReplyId = $row['TReplyId']; $this->ticket = $row['Ticket']; $this->content = $row['Content']; $this->author = $row['Author']; $this->timestamp = $row['Timestamp']; $this->hidden = $row['Hidden']; }
/** * loads the object's attributes. * loads the object's attributes by giving a TUserId. * @param $id the id of the ticket_user that should be loaded */ public function load_With_TUserId($id) { $dbl = new DBLayer("lib"); $statement = $dbl->select("ticket_user", array('id' => $id), "TUserId=:id"); $row = $statement->fetch(); $this->tUserId = $row['TUserId']; $this->permission = $row['Permission']; $this->externId = $row['ExternId']; }
/** * get language attribute of the object. */ public function getLanguage() { $dbw = new DBLayer("web"); if (!isset($this->language) || $this->language == "") { $statement = $dbw->select("ams_user", array('id' => $this->uId), "UId=:id"); $row = $statement->fetch(); $this->set($row); } return $this->language; }