public static function retrieve() { $userId = Auth::getUserId(); echo Tabs::retrieveTabs($userId); exit(0); }
public static function editTab($userId, $title, $oldTitle) { // Verify if the tab name doesn't exist $tabNameExist = true; $userTabs = Tabs::retrieveTabs($userId, 'raw'); foreach ($userTabs as $tab) { if ($tab['title'] == $title && $tab['title'] != $oldTitle) { return 0; } } $db = DbUtil::accessFactory(); $title = $db->escape($title); $oldTitle = $db->escape($oldTitle); // Change name in "tabs" table $query = "UPDATE tabs SET title = '{$title}' WHERE title = '{$oldTitle}' AND userid = '{$userId}' "; if (!$db->execute($query)) { throw new DBException(MwwException::MODEL, "Unable to edit the '{$name}' tabs in the persistant database (tab)."); } // Change name in "interface" table // TODO: Use a transaction here $query = "UPDATE interface SET tab = '{$title}' WHERE userid = '{$userId}' "; if (!$db->execute($query)) { throw new DBException(MwwException::MODEL, "Unable to edit the '{$name}' tabs in the persistant database (interface)."); } return 1; }